Advertisement

All Jokes aside, what is 6/2(1+2)?

Started by March 27, 2015 12:00 AM
115 comments, last by BaneTrapper 9 years, 5 months ago

There is a star put between the 2 and the parenthesis, which was not in the original question. Also there are additional parenthesis which clarify the expressions.

They call me the Tutorial Doctor.

This is the kind of thinking that leads to non-existent words being added to the dictionary, such as “ain’t” and “snuck”.

Just because it is common it does not mean it is correct.

.

Almost every word you use today WAS slang at some point in time . This is how English evolved to what it is now ( try attempting to read Old English ) .

A good modern example of "slang as accepted language" is the word "car" .

Of course I could get into a long winded argument of England English VS Australian English VS American English VS every other version of English .

I cannot remember the books I've read any more than the meals I have eaten; even so, they have made me.

~ Ralph Waldo Emerson

Advertisement

I think you are spot on Oberon.

Today is the first time I hear about this "special rule" for implicit multiplication, but I think I understand the logic behind it now, and how it can be useful.

I still feel like it is a bad convention though, and can easily be misunderstood. It messes with everyone who go by the logical precedence of operators according to growth, which still is what most people learn first and foremost.

The idea that a / would mean the horizontal bar in division and therefore change the precedence makes no sense. If so, what defines where the "precedence override" ends? (where does the line end?) You would still need parenthesis to show that, unless it should always mean "to the end of the expression" which doesn't make much sense either, except for very simple expressions. It only makes sense if combined with implicit multiplication, so just using the implicit multiplication rule is enough, if you want to interpret the expression this way.

Interestingly, I tried writing the equation in different ways and allowing myself to read it out naturally and I found this:

6 / 2 * b is read as "six divided by two times b"

6 / 2b is read as "six over two b"

6/2 * b is read as "six halves times b"

6/2b is read as "six halves b"

Note the spacing on the second and fourth ones. So the orthography does seem to factor into my interpretation of the expression when I don't stop to think about the precedence.

I'm still not totally sure how I came around to this way of thinking.

Undefined behavior, it could be anything.

This question is silly, like asking what ++i + i++ was.

There are mathematical laws that are absolute, but mathematical expressions are purely conventional. All parties must agreed what the expression means before any further discussions could be made. AFAIK there's no ISO standard regarding mathematical expressions, especially in ASCII form.

Of course we have some operator precedence conventions for basic arithmetic expressions that is nearly universal, but once you omit the multiplication operator, it is not a basic arithmetic expression anymore. It became ambiguous, some believe it is a normal operator, some believe it has priority. I believe both are reasonable.

Is it even a multiplication operator that was omitted? Maybe it's a function call to some function maliciously named with a symbol that look just like 2?

I could also read this as a prefix expression, and the answer will be "syntax error". PEMDAS or whatever need not apply everywhere, and the original question did not state how should I read it.

What you, Wolfram Alpha or Google gave not mean anything, It is only what a certain implementation did. Just like you can't use gcc or MSVC to answer ++i + i++.

Avoid undefined behavior in programming and in life. State clearly what you mean. And allow people to think otherwise if it is not clear enough.

Undefined behavior, it could be anything.

No, it’s not. Neither expression is undefined.


L. Spiro

I restore Nintendo 64 video-game OST’s into HD! https://www.youtube.com/channel/UCCtX_wedtZ5BoyQBXEhnVZw/playlists?view=1&sort=lad&flow=grid

Advertisement


No, it’s not. Neither expression is undefined.

Whether it is defined is undefined. Recurse.

Who are you and who am I to define what it should mean?

ISO C++ Standard says it is a syntax error, the program is ill-formed. Maybe they are right?


So the orthography does seem to factor into my interpretation of the expression when I don't stop to think about the precedence

Hmm. Very interesting. I think it is more about how we communicate the equation more than anything. We don't have the means in programming to clearly communicate a division bar without using more parenthesis. Even with the division sign, the communication is lost.

In programming we do happen to use inline notation, but I am guessing we should have a better understanding of how each language processes the numbers we put in, as well as what we intend on saying when we type such notation?

Python, for one gives, a traceback error.

On ill-formed and undefined (but related):

http://stackoverflow.com/questions/22180312/difference-between-undefined-behavior-and-ill-formed-no-diagnostic-message-requ

They call me the Tutorial Doctor.

Who are you

This is the only time in my life in which the fact that I dropped out of high school will work to my advantage.

6÷2(1+2) = 9.

b = 3
6÷2b = 1.


I originally agreed with Hodgman that this was the first time I had heard of this silly little exception.
2(1+2)? Nothing special about this, nothing exceptional.
b = 3
2b? After dropping out of high school almost all of the math I learned was through research papers, especially those focused on graphics.

I encountered this kind of notation so often I didn’t even remember it, but in every paper you will find the “2b” will always expand to 6 before the division.
I tried to find an example of this, but all I found in research papers made the order of operations clear.
It has always been somehow implicit that the order of operations would not change the results in all the papers I am finding now, but I am positive that in every case where it was not entirely explicit, it was always the case that 2b would be evaluated first. I checked Oren-Nayar, Ashikhmin-Shirley, etc., and I am not finding it, but this was an unconscious association created by studying research papers directly applicable to game programming. This is not something I learned in school (never heard of PEMDAS or any other acronyms etc.)

Usually papers are written such that, “a + 2b * 3c”, so no matter how you jumble the order of operations you still get the same result.
But I still know from papers I can’t find right now that 2b is the first thing you do, then 3c, then 2b * 3c.



All that being said, the correct answer to the original question is 9.


L. Spiro

I restore Nintendo 64 video-game OST’s into HD! https://www.youtube.com/channel/UCCtX_wedtZ5BoyQBXEhnVZw/playlists?view=1&sort=lad&flow=grid

I still hold that it is 9 also with the same reasons I presented, but I can say it is both because the question is technically ill-formed since there is no approved single convention to establish the correct form.

They call me the Tutorial Doctor.

This topic is closed to new replies.

Advertisement