nocturne@slrpnk.net to Showerthoughts@lemmy.world · 15 days ago(-27)^2/3message-squaremessage-square12fedilinkarrow-up130arrow-down17file-text
arrow-up123arrow-down1message-square(-27)^2/3nocturne@slrpnk.net to Showerthoughts@lemmy.world · 15 days agomessage-square12fedilinkfile-text
minus-squaremschae@discuss.mschae23.delinkfedilinkEnglisharrow-up14·15 days ago-27^2/3 would come out to a different number, because the exponentiation has a higher precedence than the negation
minus-squareprintf("%s", name);@piefed.blahaj.zonelinkfedilinkEnglisharrow-up5·edit-215 days agoAh, so without parentheses, it would be: x = -27^2 x / 3? That doesn’t sound very intuitive though…
minus-squaremschae@discuss.mschae23.delinkfedilinkEnglisharrow-up5·edit-215 days agoyup: (-27)^2/3 = ((-27) ^ 2) / 3 -27^2/3 = (-(27 ^ 2)) / 3 The reason is that you almost always want the negation to happen after the exponentiation, because it otherwise wouldn’t have any effect (at least when the exponent is even).
-27^2/3would come out to a different number, because the exponentiation has a higher precedence than the negationAh, so without parentheses, it would be:
x = -27^2
x / 3?
That doesn’t sound very intuitive though…
yup:
(-27)^2/3=((-27) ^ 2) / 3-27^2/3=(-(27 ^ 2)) / 3The reason is that you almost always want the negation to happen after the exponentiation, because it otherwise wouldn’t have any effect (at least when the exponent is even).
Thanks! 😃