|I hate re-inventing something that's already been done. In this case, probably several times. Basically, "you can't", but you can fudge it by treating the numbers as a string: remove the dot, do the math, then re-insert the dot as per the rules of math which I don't remember. You can search the forum on "decimal division batch" or "decimal calculation batch" etc. and probably dredge up the solutions. Me, I would just use vbscript, which is native to windows and saves about 100 lines of code. Here's a front-end vbscript for doing command-line calcs:|
'Simple commandline calculator, but handy to have around (batch math is feeble)
'(a "front-end" to vbscript "eval".
'To use (example): cscript /nologo calcit.vbs ((172+6)*3) * 2^8/34 mod 4
'or another, demonstrating fractions: 12.7 / .22
'Also note it will do hex-to-decimal conversion and hex math, like: calcit &h70 + &hC, or &h70 + 12
'(but the results always rendered in decimal, alas.)
'Will also concatenate numbers using "&".
if t.count=0 then
cout.write ("enter the math: ")
do while len(aa)>0
bb=eval(bb & aa)
for i=0 to t.count-1