+ 2

Logical operator. Exponentiation.

Why in the case of 2**3**4 does not get the answer 4096? Explain, I will be grateful.

16th Mar 2018, 5:36 AM
Alexis
Alexis - avatar
2 odpowiedzi
+ 11
(2**3**4) case 1) ((2**3)**4) //this is 4096 case 2) (2**(3**4)) //since the only operator here is ** , so no role of precedence ...here is the role of associativity , might the associativity of operator is from right to left ... so operation done first from right hand side
16th Mar 2018, 5:43 AM
Gaurav Agrawal
Gaurav Agrawal - avatar
+ 8
Exponentiation takes presedence and starts outside in. so it does 2**81 instead of 8**4 If you want 4096, ie 8**4 then use (2**3)**4 the brackets will force it to calc the 8 first.
16th Mar 2018, 5:44 AM
Louis
Louis - avatar