View Single Post
  #11   Report Post  
Posted to microsoft.public.excel.misc
 
Posts: n/a
Default Order of calculation

Louise wrote:
so, the brackets around 10+10 tells Excel to do that bit first,
before it continues with the rest of the calculation.
What do the brackets around 10+10*2+2 tell Excel to do?
Is it always the very last part of the calculation that doesn't
have brackets around it?


No. I suggest that you use Excel Help. Enter "operator precedence"
and select the link "The order in which Excel performs operation".
Hopefully that clarifies things for you.

As you can probably tell, maths was never my strongest point
and I don't understand what the second set of bracets are
instructing Excel to do.
[....]
"Roelof van Wyk" wrote:
=((10+10)*2+2)*10


Notice that that could be written 10*((10+10)*2+2), demonstrating
that it is not always "the very last part of the calculation that
doesn't have brackets [sic] around it".

As you read left to right, when you see a right parenthesis,
evaluate everything left-to-right until you encounter the matching
left parenthesis. So, first we do "10+10" (20), then we evalutate
"20*2 + 2" (42), and finally we do "42*10" (420). The key is: we
do "20*2" before we do "...+2". If we wanted to do "2+2" before
we do "20*...", we would have to write (10+10)*(2+2)*10, which
yields 20*4*10 = 800.