Single / Double rounded decimal places in DOS

October 13, 2010 at 07:58:23
Specs: Windows XP
In DOS batch file, is there any way to retrieve double rounded decimal places after mathematic calculations ?

See More: Single / Double rounded decimal places in DOS

Report •

October 13, 2010 at 08:22:19
Not obvious how you'd do math in DOS.

In NT/XP you can do INTERGER math with SET /A.

Life is too important to be taken seriously.


Report •

October 13, 2010 at 08:35:44
I did following code in NT/DOS batch file, where I am looking for double precision value for ,=(%var2%/%var1%)*100. It is printing 20.58689603, Instead i need 20.59

FOR /F "eol=; tokens=2,4,5*" %%i in (XXX.TXT) DO (
if %%i==BNT7VP call :para1 "%%i","%%j","%%k"
set var1=%2
set var1=%var1:,=%
set var2=%3
set var2=%var2:,=%
echo ,%1,%2,%3,=(%var2%/%var1%)*100 >> sam.csv

Report •

October 14, 2010 at 04:26:32
DOS batch (cmd.exe) is not the correct tool to do maths and many other stuff. Its not a programming language. In your system, you should have you can try using it.

WScript.Echo Round(WScript.Arguments(0),2)

save the above as myround.vbs then

C:\test>cscript //nologo test.vbs 1234.333224

GNU win32 packages | Gawk

Report •

Related Solutions

Ask Question