git.net

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]# Operator precedence problem

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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. [snip] 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: bc (a**b)**c = a c b a**(b**c) = a -- To email me, substitute nowhere->runbox, invalid->com.

- Prev by Date:
**I'm wrong or Will we fix the ducks limp?** - Next by Date:
**Operator precedence problem** - Previous by thread:
**Operator precedence problem** - Next by thread:
**Operator precedence problem** - Index(es):