Σάββατο 21 Δεκεμβρίου 2024

using left or right associative for exponents;

M2000 use left associative for exponents:

So 3+4*2/(1-5)^2^3 return 3.001953125

but unary + and - are right associative

So 3+4*2/(1-5)^+2^3   return 3.0001220703125 because the + between ^ and 2 is a unary +.

It is the same as 3+4*2/(1-5)^+(2^3) or 3+4*2/(1-5)^(2^3)

Old versions of M2000 always using left associative for exponents, so the unary + or - are all computed for the following operand not the entire following expression, so  3+4*2/(1-5)^+2^3 was like 3+4*2/(1-5)^(+2)^3 same as  3+4*2/((1-5)^2)^3

Also old versions -2^2 return 4, because was like (-2)^2 but the current version 12 return -4 because the -  and the - as unary are left associative wich means -(2^2) or -(4) or -4.

Old version 5+-2^2 return 9, because after + we have the -2^2 which is 4. so we have 5+4=9

Current version 5+-2^2 return 1 because -2^2 is -4 so  5 + -4 is 5-4 is 1,



Δεν υπάρχουν σχόλια:

Δημοσίευση σχολίου

You can feel free to write any suggestion, or idea on the subject.