Solved Is it posible to use decimal calculations in cmd?

June 26, 2013 at 15:32:20
Specs: MS-DOS 8+ (WINDOWS XP APLICATION "CMD.EXE" RUNNING TRUGHT "NTVDM.EXE" AS AN APPLICATION INSIDE WINDOWS XP), 4 CORES OF 2.4 GHZ/AND 4GB OF RAM
hay my friends. ;)

i am just woundering, can anyone tell me is there a way to use decimal calculations in cmd (batch scripts) language?

i am writing my own program in cmd programming language, and i want to do a percent calculations (for progress bar). but cmd allways as a resoult of dividing returns full number. and i need a decimal number to be able to calculate percentage.

is there any dos utility which can be used as a patch for ms-dos 8 (windows xp cmd.exe over ntvdm.exe (or even better 32 bit dos utility without ntvdm.exe)) which can do decimal calculations?
if there is, i will install it in dos, and use it in cmd as a new command.
because cmd does not support calculations with decimal numbers (just full numbers).


thank you.


See More: Is it posible to use decimal calculations in cmd?

Report •

#1
June 26, 2013 at 18:37:55
✔ Best Answer
You already have one, if you have vbscript, using the EVAL function. Or, alternatively, you can just muliply the numerator by 100 before the division to get a whole number, f/e:
:: this is your raw numerator (number that have been processed, of files, sectors, etc)
set b=12
:: this is the denominator (total number of files, or sectors, or whatever)
set c=32
:: now multiply the numerator before doing the math:
set /a b*=100
:: now do the math
set /a perc=b/c

but of course you can combine the math:
set /a perc=b*100/c

And if you want to use vbscript, here's a front-end:
http://www.computing.net/howtos/sho...

Or just write your own for your specific needs.


Report •

#2
June 26, 2013 at 19:23:38
THANK YOU, THIS HELPS. ♥

Report •
Related Solutions


Ask Question