Operator precedence problem
On Mon, 6 Jun 2016 02:24:37 +1000, Chris Angelico <rosuav at gmail.com> wrote:
> On Sun, Jun 5, 2016 at 4:53 PM, ICT Ezy <ictezy at gmail.com> wrote:
>>>>> 2 ** 3 ** 2
>> Answer is 512
>> Why not 64?
>> Order is right-left or left-right?
> This example follows the mathematical standard; you start from the
> "top" (the right hand side), and work your way down.
This is almost certainly why top-down was the desirable choice. And
as for why mathematicians chose top-down (probably long before any
programming-language designer faced the decision), note that this
convention allows you to write both (a**b)**c and a**(b**c) without
parentheses, making expressions cleaner than otherwise:
(a**b)**c = a
a**(b**c) = a
To email me, substitute nowhere->runbox, invalid->com.