Bracket not taken into account in math expression
Brought to you by:
ddaglas
The mathematic expression:
a=(i-j)/(k*m)
with i=206
j=6
k=7
m=2
gives 57.1429 but it should be 14.2857
Bracket are not taken into account for operation priority.
Thanks
millette_jocelyn@hotmail.com
Try this program to see what I mean:
(It seems to be multiplication in bracket that makes funny thing)
BEGIN{
a=100
b=5
c=3
d=2
e=7
f=77
print "506= " a*b+c*d
print "117= " a+b*c+d
print "494= " (a-34)*7+int((a-3)/3)
print "31.6666= " (a-b)/c
print "15.8333= " (a-b)/(c*d)
print "742= " (a-b*(c-d))*e+f
print "2464= " (int((a-b-1)/c)+1)*f
print "996= " (a-1)*b*2+c+(f-d)%(c*2)
print "996= " (a-1)*b*2+c+(f-d)%6
print "-15.833333 = " (a-b)/(c-d-e)
print "482= " a+(b*(f-d)+e)
print "124= " a+(b-1)*c*d
}