Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Yes, that answer is incorrect since it breaks with calculator conventions. The contents of the parentheses are calculated first (P in PEMDAS), and then the multiplication is done later (MD in PEMDAS). Implicit multiplication (which does not explicitly use a multiplication sign) has the same priority as any other multiplication:

  a/b(c) = a/b*c = (a/b)*c
Since SpeedCrunch only accepts input in a single line, this would be the least unexpected way to interpret the expression, and consistent with how graphing calculators operate.

A horizontal fraction bar, which SpeedCrunch does not support (since it only accepts single-line input), implies parentheses around the numerator and denominator. For example:

  ax
  -- = (ax)/(by) = (a*x)/(b*y)
  by
compared to

  ax/by = a*x/b*y = ((a*x)/b)*y
(If the above is not displayed correctly, please view this comment on the HN website.)

Implicit multiplication is a point of frequent confusion:

- https://www.nytimes.com/2019/08/05/science/math-equation-pem...

- https://www.themathdoctors.org/order-of-operations-implicit-...

To guarantee that the expression does not get misinterpreted, the person writing the expression should always add parentheses/brackets and explicit multiplication signs, or use horizontal division bars where possible, to make the expression unambiguous.



Not even calculators agree on this. Here's a picture of my Casio fx-83ES and fx-83GT calculators giving different answers to "8/2(2+2)": https://i.imgur.com/SsKUQrE.jpg

Both answers are completely, 100% correct according to the operator precedence table in their manuals. I also have a Casio fx-83MS and fx-991ES, both give 1 as the answer.

Others I have are a Casio fx-570CD and a Casio statistical calculator I don't remember the model of, neither of which support implicit multiplication, and a SwissMicros DM42, which is RPN and doesn't have to deal with operator precedence.

I don't even know why I have half of these...


Looking at this issue and then trying Qalculate! as some of the other commenters to this post have mentioned.... I tried 1/2(-9.8) and it calculated it as -0.05102040816 as I was doing the entry. As soon as I hit enter, however, it popped open a dialog box saying "The expression is ambiguous" and asked me to select an interpretation of expressions with implicit multiplication, setting a preference for later use. The choices were:

Implicit multiplication first: 1/2x = 1/(2x); Conventional: 1/2x = (1/2)x; Adaptive: 1/2x = 1/(2x); 1/2 x = (1/2)x

So their answer is to just ask the user what to do! It won me over with that.


That's the perfect way to deal with this case. I've been using Qalculate! for quite some time, but never saw this dialog because I've apparently never entered an ambiguous expression before. Thanks for sharing this.


I have to say, it's really disappointing to see similar models from the same brand act differently. Thanks for testing this out and shedding more light on this issue.


÷ https://en.wikipedia.org/wiki/Division_sign

avoids this entirely.

or if you wanna be really fkn nerdy:

∕, instead of /


Almost every one of those Facebook reposts with an ambiguous math equation features an obelus. It only seems to create confusion.


You're right. The division sign is also unambigious. Unfortunately, it's not usually found on keyboards so many people are accustomed to using slashes.

SpeedCrunch and other calculator apps still need to have an unambiguous way of interpreting the expression when the user types or pastes in a slash. The apps could convert slashes to division signs before displaying them on the screen, since that's how the symbols should be interpreted. This is how GNOME Calculator resolves the ambiguity.


Nobody uses that symbol after grade school.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: