How do I set a precision to the SET arithmetic operation on divisions?
eg. SET /A t=3/4
But that gives result as '0
' and not '0.75
' ( I want at least 2 decimal places )
Or is there any other method for such arithmetic operations (using other than "set /A
" ) to happen in Batch files?
Answer
If you're using Microsoft's CMD
, then what Nifle said applies. However, if you are using JP Software's TCC/LE to replace it, not only is there another way to do arithmetic in command scripts, but it is not limited to integer arithmetic and the precision of the calculations is controllable.
TCC/LE supports the /A
option to the SET
command, of course. But, as the documentation states, one can also perform arithmetic with the @EVAL[]
variable function:
SET T=%@EVAL[3/4]
The output precision of the %@EVAL[]
calculation is a controllable option, settable in three ways:
No comments:
Post a Comment