Logical operator. Exponentiation. | Sololearn: Learn to code for FREE!

+2

Logical operator. Exponentiation.

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

3/16/2018 5:36:36 AM

Alexis

2 Answers

New Answer

+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

+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.