2^2*2+2=4 MAJOR WRONG
Even if it fubars the operator priority, it should work left-to-right, correct? Then it should do:
2^2*2+2
4*2+2
8+2
10
Also, note in whatever documentation that it wants points, and not commas. (EU vs US rules, or Dutch vs English)
15+5*5=40, nice and correct. (Ergo, it does seem to do some kind of operator preference.)
5*5+15=25.
(5*5)+15=40. So it works well with brackets.
It also exits without error on any NAN entry.
2*4+7=8. Pretty wrong. It seems that if you do x*y+z you will always get something odd. Perhaps it gives you just x*y, and forgets z.
Yup, it does. x*y+z gives you x*y.
Also seems x/y-z gives you x/y.
z+x*y gives you a correct answer. (z+(x*y)).
z-x/y gives you z-(x/y), correct as well.
3^-5 gives an ugly crash. (Want the MS bugreport? Msn at
[email protected] )
Seems to reproduce for x^-y.
Ditto for x^(-1*y).
However, x^(y-z), when z>y, works, and gives a correct answer.
BTW, can you make it so it'll take an expression as command line arg, and return the result? I could write a testing thing with random expressions in no time.
I'll test some more after dinner, but an argument thingy would be great.
EDIT: Got source? I might be able to read the C and find the bug, if you'd allow a total beginner to touch the code.....