Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

SET /A var=expression=digits

May
12,834
163
I don't know when it stopped working, but here's v20.
Code:
v:\> set /a zz=1/3=5
0.33333

And here's v21.
Code:
v:\> set /a zz=1/3=5
5
5

v:\> set /a zz=1/3
0

v:\> set /a zz=1+2
3

In the first of those three, the (wrong) result was echoed twice. In the second, the result is just wrong.
 
SET /A was changed in v21 for CMD compatibility (integer only). If you want floating point, use @EVAL.
That's a shame!

Obviously, the old SET /A mechanism is still in place and works with floating point numbers ... sometimes.

Code:
v:\> set /a zz=atan(pi)
1.2626272557

v:\> set /a zz=.5**2
0.25

v:\> set /a zz=log10(20)
1.3010299957

v:\> set /a zz=1.22+4.7
5.92

v:\> set /a zz=sin(2)
0.9092974268

v:\> set /a zz=1.22*4.7
5.734

v:\> set /a zz=.25 ** .5
0.5

v:\> set /a zz=exp(2.2)
9.0250134994

v:\> set /a zz+=exp(2.2)
18.0500269988
 

Similar threads

Replies
4
Views
2K
Back
Top