# Simple arithmetic

• Comments posted to this topic are about the item Simple arithmetic

Don Simpson

• Nice question, thanks.

Need an answer? No, you need a question
My blog at https://sqlkover.com.
MCSE Business Intelligence - Microsoft Data Platform MVP

• This was removed by the editor as SPAM

• i saw lots of people on social sites having problems with:

1+1+1+1+1+1+1+1+1+1+1+1x0+1 = ?

most of the answers was 1. So saying Simple may apply differently to others :hehe:

• It's. Too. Early. For. This. 🙂

• It was simple math, but also a simple exercise in clear thinking, something I would think that most people who work in databases would be good at. Thanks.

• Emil Bialobrzeski (12/10/2014)

i saw lots of people on social sites having problems with:

1+1+1+1+1+1+1+1+1+1+1+1x0+1 = ?

most of the answers was 1. So saying Simple may apply differently to others :hehe:

Slightly unfair question, though, because the answer depends on operator precedence. For instance, I was never taught at school that multiplication takes priority over addition, and if you just process that statement left to right, then the answer *is* 1--you add a load of 1s together, multiply that by zero, and add 1 to the result.

• paul.knibbs (12/10/2014)

Emil Bialobrzeski (12/10/2014)

i saw lots of people on social sites having problems with:

1+1+1+1+1+1+1+1+1+1+1+1x0+1 = ?

most of the answers was 1. So saying Simple may apply differently to others :hehe:

Slightly unfair question, though, because the answer depends on operator precedence. For instance, I was never taught at school that multiplication takes priority over addition, and if you just process that statement left to right, then the answer *is* 1--you add a load of 1s together, multiply that by zero, and add 1 to the result.

++1

Thanks & Best Regards,
Hany Helmy
SQL Server Database Consultant

• paul.knibbs (12/10/2014)

Emil Bialobrzeski (12/10/2014)

i saw lots of people on social sites having problems with:

1+1+1+1+1+1+1+1+1+1+1+1x0+1 = ?

most of the answers was 1. So saying Simple may apply differently to others :hehe:

Slightly unfair question, though, because the answer depends on operator precedence. For instance, I was never taught at school that multiplication takes priority over addition, and if you just process that statement left to right, then the answer *is* 1--you add a load of 1s together, multiply that by zero, and add 1 to the result.

Wow, really? Proper order of operations is fairly important in most high level maths. I remember having drills wherein we had to take math expressions and add parentheses to show how the statement should be parsed.

• Xavon (12/10/2014)

paul.knibbs (12/10/2014)

Emil Bialobrzeski (12/10/2014)

i saw lots of people on social sites having problems with:

1+1+1+1+1+1+1+1+1+1+1+1x0+1 = ?

most of the answers was 1. So saying Simple may apply differently to others :hehe:

Slightly unfair question, though, because the answer depends on operator precedence. For instance, I was never taught at school that multiplication takes priority over addition, and if you just process that statement left to right, then the answer *is* 1--you add a load of 1s together, multiply that by zero, and add 1 to the result.

Wow, really? Proper order of operations is fairly important in most high level maths. I remember having drills wherein we had to take math expressions and add parentheses to show how the statement should be parsed.

Order of operations is an arbitrary syntax decision, and not necessarily implemented consistently in programming languages. Yes there is a standard in mathematics but it could easily have been different. It could have been that there was no decision at all and that the only way to guarantee order was with parentheses. Luckily parentheses are given priority, at least in every language I've come across. Doesn't hurt to add them in anyway, otherwise questions like that are just syntax memory tests rather than logic tests.

back to the real topic. I enjoyed the question. I suppose that depending on the underlying implementation, it could save a little memory 🙂

• Nice math swap. Now is there something like that for strings?

• Nice but simple question: I'm wondering why it worths 2 points

• Hany Helmy (12/10/2014)

paul.knibbs (12/10/2014)

Emil Bialobrzeski (12/10/2014)

i saw lots of people on social sites having problems with:

1+1+1+1+1+1+1+1+1+1+1+1x0+1 = ?

most of the answers was 1. So saying Simple may apply differently to others :hehe:

Slightly unfair question, though, because the answer depends on operator precedence. For instance, I was never taught at school that multiplication takes priority over addition, and if you just process that statement left to right, then the answer *is* 1--you add a load of 1s together, multiply that by zero, and add 1 to the result.

++1

I think you need a refund on your base math education. BEDMAS was drilled into us here in the Great White North starting at age 10 (Grade 5), and continued through to end of Math in high school.

Since BEDMAS might be unknown

B - Brackets

E - Exponents

DM - Division / Multiplication

• Xavon (12/10/2014)

paul.knibbs (12/10/2014)

Emil Bialobrzeski (12/10/2014)

i saw lots of people on social sites having problems with:

1+1+1+1+1+1+1+1+1+1+1+1x0+1 = ?

most of the answers was 1. So saying Simple may apply differently to others :hehe:

Slightly unfair question, though, because the answer depends on operator precedence. For instance, I was never taught at school that multiplication takes priority over addition, and if you just process that statement left to right, then the answer *is* 1--you add a load of 1s together, multiply that by zero, and add 1 to the result.

Wow, really? Proper order of operations is fairly important in most high level maths. I remember having drills wherein we had to take math expressions and add parentheses to show how the statement should be parsed.

Yes, operator precedence is very important. That's why both computer languages and mathematical calculi and notations define operator precedence rigorously. There are pleny of languages/calculi where precedence is defined to be purely left to right except unless there are special cases like for example the use of brackets or some other precedence modifying syntax (eg in mathematics the lambda calculus and some of its derivatives, and in computing several programming languages based on them) and also notations where precedence is purely left to right or purely right to left - think of Polish notation and reverse Polish notation, which are respectively left to right and right to left: both are commonly used in both maths and computing. Given the expression 1+1x0+1 the value could be 3,1, or 2 depending on the precedence rules so unless either the language/notation is specified or the precedence rules are defined without mentioning the language/notation there's no knowing what the value is. Sure, in a junior high school maths test the answer will probably be 2 because no-one has yet been taught that there's more than one possible notation, but that doesn't mean that that's always the right answer.

Tom

• davoscollective (12/10/2014)

Xavon (12/10/2014)

paul.knibbs (12/10/2014)

Emil Bialobrzeski (12/10/2014)

i saw lots of people on social sites having problems with:

1+1+1+1+1+1+1+1+1+1+1+1x0+1 = ?

most of the answers was 1. So saying Simple may apply differently to others :hehe:

Slightly unfair question, though, because the answer depends on operator precedence. For instance, I was never taught at school that multiplication takes priority over addition, and if you just process that statement left to right, then the answer *is* 1--you add a load of 1s together, multiply that by zero, and add 1 to the result.

Wow, really? Proper order of operations is fairly important in most high level maths. I remember having drills wherein we had to take math expressions and add parentheses to show how the statement should be parsed.

Order of operations is an arbitrary syntax decision, and not necessarily implemented consistently in programming languages. Yes there is a standard in mathematics but it could easily have been different. It could have been that there was no decision at all and that the only way to guarantee order was with parentheses. Luckily parentheses are given priority, at least in every language I've come across. Doesn't hurt to add them in anyway, otherwise questions like that are just syntax memory tests rather than logic tests.

back to the real topic. I enjoyed the question. I suppose that depending on the underlying implementation, it could save a little memory 🙂

Can you show me an example of any programming language that does not support the mathematical agreed upon order of operations?

The question above is NOT a syntax memory test, it tests your understanding of the order of operations for math.

_______________________________________________________________