Click here for important information about

Solved How Do You Add Divison To Batch Files

May 29, 2013 at 19:13:21
Specs: Windows Vista
I know You Can Do it like this
set /a answer=%number1% / %number2%
then you get it.
but how to you get it to do points (points= . )
Example : 1.5

If You Know How Please Tell Me and Thank You

See More: How Do You Add Divison To Batch Files

May 29, 2013 at 20:02:10
✔ Best Answer
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 "&".
set con=wscript.stdin
set cout=wscript.stdout
set t=wscript.arguments
if t.count=0 then
cout.write ("enter the math: ")
do while len(aa)>0
bb=eval(bb & aa)
cout.writeline("cur.ttl: --------")
dim a(99)
for i=0 to t.count-1
aa=aa&" "&t(i)
end if
'========= end

Report •
Related Solutions

Ask Question