News for hackers. Stuff that matters.
Re:Why is there not a Square Root button in calc.exe? by user24 on Saturday August 21, 2010 @05:05PM (#1623663)
Another interesting calc.exe quirk:

On "Standard" view, type:

1 + 2 * 3 =

Answer comes back as 9

Switch to "Scientific" view and type the same,

Answer comes back as 7

The reason (of course) is operator precedence; in standard mode it's interpreted as "1 + 2 =" then "* 3 =", while in scientific view it respects BODMAS.

But to me it's counter-intuitive that changing the View also changes the Mode of operation.

If they'd just named that menu "Mode" instead of "View" I'd be fine with it.

Re:Why is there not a Square Root button in calc.exe? by andrerobot on Saturday August 21, 2010 @05:32PM (#1623708)
I've used cheap scientific calculators that perform operations from left to right. It's awful when you are answering a uni exam and you don't know why the results you get looks fishy.

On computer calculators, I always type "1 + 2 * 3 =" as "2 * 3 =", "+ 1 =" because I learned the hard way that I can't asume that a calculator is going to respect order of precedence or not.

Re:Why is there not a Square Root button in calc.exe? by sprout on Saturday August 21, 2010 @05:42PM (#1623720)
I think the first calculator I used was one of those. It took me till college and programming before I really properly learned precedence because I never trusted any calculator I was using, and always used parentheses.

This also kind of influences my programming, probably for the better - I would rather use parens and be clear than be ambiguous and trust that my interpreter and I agree on what has proper precedence.

Re:Why is there not a Square Root button in calc.exe? by jacquesm on Saturday August 21, 2010 @06:48PM (#1623806)
The 9 is just plain wrong. Operator precedence is not a scientific thing, that's a grade school thing.
Re:Why is there not a Square Root button in calc.exe? by dchest on Saturday August 21, 2010 @06:53PM (#1623814)
(1 + 2) * 3
Re:Why is there not a Square Root button in calc.exe? by jacquesm on Saturday August 21, 2010 @06:54PM (#1623815)
You've just changed the precedence.
Re:Why is there not a Square Root button in calc.exe? by dchest on Saturday August 21, 2010 @07:01PM (#1623825)
Thanks, I know. I meant that most non-scientific calculators I used worked this way.
Re:Why is there not a Square Root button in calc.exe? by jacquesm on Saturday August 21, 2010 @07:06PM (#1623830)
That doesn't make them less broken!

And if the software has the capability to do it right why bother building in a 'broken' mode.

Re:Why is there not a Square Root button in calc.exe? by evilduck on Saturday August 21, 2010 @08:16PM (#1623927)
It reflects the old paper tape usage model, where you typed it in in the order you wanted to perform the operations.

Apple's Calculator.app works similarly, although their default state is better. If you open up the "Shown Paper Tape" window, and type "1 + 2 * 3 [enter]", it replies "1 + 2 * 3 = 7" If you then type "1 + 2 [enter]", it replies "1 + 2 = 3", then if you hit " * 3 [enter]" it replies "1 + 2 * 3 = 9".

Re:Why is there not a Square Root button in calc.exe? by jacquesm on Saturday August 21, 2010 @08:39PM (#1623958)
Yes, I can see how the 'enter' would force the precedence.

The '=' key will do the same.

Re:Why is there not a Square Root button in calc.exe? by user24 on Saturday August 21, 2010 @07:20PM (#1623850)
I think it's because non-mathematical people tend to use calculators in the 'broken' way. Their thought process is "ok, 1+2" (implicit equals) "times 3".
Re:Why is there not a Square Root button in calc.exe? by dchest on Saturday August 21, 2010 @06:41PM (#1623796)
Mac OS X Calculator gives 7 in any mode. Wow, thanks for the information.