0

I need help with getting the "time to target" to show as minutes and seconds but i have no idea how.

@echo off
title torpedo calculator
:main

echo Menu:
echo 1.Torpedo Solution
echo 2.Exit
set /p ch=Enter your choice 

if %ch%==1 goto torp
if %ch%==2 goto exit


:torp
cls
set /p a=Range to target: 
set /p e=Bearing to target:  
set modify=700
set /a "c=%a%-%modify%""
set /a "d=%c%/43"
set /a "f=%a%/43"


cls
echo FIRING SOLUTION
echo Fire from the side the target is on
echo Activation = %d%
echo Bearing = %e%
echo Time to target = %f%
pause
goto main

:exit
timeout /t2
exit

in the code i have posted /a "f=%a%/43" calculates the time to target in seconds. so for example Range to target is 6700, the time to target would be 155. I have tried to divede that number by 60 but only get 2 as an answer, no decimal point. I hope i have explained that so it makes sense as i'm new to coding :D really appreciate any help.

Didz
  • 1
  • 1
    I suggest you to review [this answer](https://stackoverflow.com/questions/9922498/calculate-time-difference-in-windows-batch-file/9935540#9935540) – Aacini Apr 21 '23 at 04:52
  • 1
    Batch variables are **always** strings. The mathematical functions available convert the variable contents to numerics to perform the calculations, then back again to strings to be assigned or `echo`ed and process/produce only 32-bit integers. Avoid single-letter variable-names as they can be confused with loop-control `metavariable` names which are also single letters. minutes=totalseconds/60. seconds=totalseconds-(minutes*60) If you want to display a leading `0` then add 100 and use `%var:~-2%` (See `set /?` from the prompt for documentation) – Magoo Apr 21 '23 at 07:36

0 Answers0