Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

10.4: Be aware of a Calculator widget bug System 10.4
Tiger only hintJust a heads-up when using the Calculator widget in Dashboard. Apple fixed the calculator bug in Panther (it was present in Jaguar), but the bug made it back into the Dashboard Widget in Tiger. The issue is the adherence to the PEMDAS order of operations we all learned in grade school: parentheses, exponent, multiplication and division, addition and subtraction. An example:

Panther and Tiger calculator app:
1 + 2 * 3 = 7 (correct)

Dashboard Widget and Jaguar app:
1 + 2 * 3 = 9 (incorrect)

Hopefully they'll fix this one in a future update...
    •    
  • Currently 2.25 / 5
  You rated: 4 / 5 (4 votes cast)
 
[22,457 views]  

10.4: Be aware of a Calculator widget bug | 74 comments | Create New Account
Click here to return to the '10.4: Be aware of a Calculator widget bug' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
10.4: Be aware of a Calculator widget bug
Authored by: Zee on May 24, '05 10:09:50AM

The whole calculator app has problems in Tiger. I reported this to Apple but basically if I open the calculator app (Basic, let's say) then close the window (but not quit the app) it USED to be that if you clicked the app in the dock the window would open back up, no go. Try selecting Basic from the menu in the app and it STILL won't come back. Now try quitting the calculator app from the application menu, won't quit. You can only quit it from the dock menu and then launch it again to get the calculator window back.



[ Reply to This | # ]
10.4: Be aware of a Calculator widget bug
Authored by: lpp on May 24, '05 10:26:24AM
Have you seen this thread? I had similar problems and found this to be the source of my troubles.

[ Reply to This | # ]
Make a new one?
Authored by: jason mark on May 25, '05 10:04:19PM

I haven't had time to install Tiger yet, so maybe I missed something, but isn't the point of "widgets" that you can just make your own calculator *fairly* easily? Considering all the effort going into this post, I imagine it's a good candidate for a "pick of the week".

:)



[ Reply to This | # ]
10.4: Be aware of a Calculator widget bug
Authored by: cranfordio on May 24, '05 10:25:00AM

This is not necessarily a bug, it is the way it is supposed to work. If you pick up any calculator and type 1 + 2 * 3 you will always get 9. In fact, in my personal opinion, I think the other way is a bug, because it assumes that I always want to multiply, or divide, before I want to add or subtract.



[ Reply to This | # ]
10.4: Be aware of a Calculator widget bug
Authored by: Han Solo on May 24, '05 10:36:50AM
No, this is clearly a bug. At one time Apple attempted to finesse it by having the standard order of operands work properly in "scientific" mode, but this incorrect left-to-right order (i.e., not recognizing the operator precedence that everyone (should have) learned in junior high, if not earlier) in "basic" mode. Other than cheap-o $5 models, any decent calculator will get the precedence correct. Why should a Dashboard widget on a $500 - $2500 computer imitate the mathematical errors of a $5 calculator knock-off? Sorry, I'm not interested in a flame war, but I cannot see the justification.

In any event, this hint is very helpful, as the lack of consistency is arguably even worse than having it incorrect. Thanks.

[ Reply to This | # ]

10.4: Be aware of a Calculator widget bug
Authored by: chabig on May 24, '05 10:52:17AM

Different calculators behave differently, even in the physical world. As you said, $5 cheap-o calculators have always worked this way. To me, that's exactly what the calculator widget is supposed to be modeling. And the calculator shows the intermediate results, so you ought not be surprised with your final answer.

Chris



[ Reply to This | # ]
10.4: Be aware of a Calculator widget bug
Authored by: cranfordio on May 24, '05 10:52:43AM

Actually, I have a fairly expensive TI graphing calculator that when I enter the proplem in that order always gives me the answer of 9. Assuming that this was a written out problem then yes the answer should be 7, but when you enter it into a calculator it will always to the math the order in which you enter it. Which would mean it does the addition first then the multiplication. Every calculator I have ever used does it this way. The calculator in Windows even does it this way. So the way I see it, if every calculator, since there were calculators, has done it a certain way, then that is the correct way.



[ Reply to This | # ]
10.4: Be aware of a Calculator widget bug
Authored by: cybergoober on May 24, '05 11:06:00AM

Right. Notice that, using the problem in the original post, when you hit the "x" the screen displays"3" from the previous 1+2 operation.

Seems to be the way it was intended to work...



[ Reply to This | # ]
10.4: Be aware of a Calculator widget bug
Authored by: Spartacus on May 24, '05 11:47:16AM

In fact, the Windows calculator behaves differently whether it's in basic or scientific mode. Basic mode ignores operation precedence and scientific mode follows it, just like real world basic and scientific calculators do.

Note that calculators that follow precedence rules usually (always?) have parentheses buttons.



[ Reply to This | # ]
10.4: Be aware of a Calculator widget bug
Authored by: diamondsw on May 24, '05 11:59:58AM

Sorry, but you're wrong. I just pulled out both my TI-35X and TI-85 (can't believe the batteries still work after ten years) and both give 7, which is the correct answer.

Mathematics is not open to debate or your personal preference. Order of operations is correct, left to right is wrong. Period.



[ Reply to This | # ]
10.4: Be aware of a Calculator widget bug
Authored by: sdewidt on May 24, '05 01:14:07PM

I don't know, but I think the problem is that two different methods of inputing the numbers are being talked about. In other words, if you input "1 + 2" and hit enter (or equals) you get "3". Then if you hit '*3' you get "9". But if you input "1 + 2 * 3" all on the same line and then hit enter you get "7", because it follows the standard order of operations. I think this is where the misunderstanding is coming from on the Ti calculators. I'm not sure about the Mac, since I don't have one in front of me right now.



[ Reply to This | # ]
10.4: Be aware of a Calculator widget bug
Authored by: melvinwalker on May 24, '05 01:20:48PM

You keep saying this, and you don't seem to realize that it's irrelevant.

Most cheap calculators work on just one operation at a time, unlike standard infix mathematic convention. They are cheap tools for simple operations. This calculator is designed to work like them.

A person doing more complex math on one of these (heaven forbid) would OF COURSE type 2 x 3 =, then + 1 =, since he understands how his tool works. If his tool doesn't work as he desires, he has the wrong tool. These calculators are designed for balancing your checkbook, not doing your math homework.

The kind of calculator this emulates can be had for next-to-nothing. We have maybe 5 of these around the house, 2 of which we can't find. They are disposable. They are nearly ubitquitous, and it wouldn't surprise me if billions are sold each year worldwide. If it's the wrong tool for you, so be it.



[ Reply to This | # ]
Order of operations
Authored by: MattHaffner on May 24, '05 02:13:03PM

"Mathematics is not open to debate or your personal preference. Order of operations is correct, left to right is wrong. Period."

I'm fairly certain that this order of operations that we commonly use is convention, not anything intrinsic to math. So, yes, it is a personal preference. One that most of us like to use in order to communicate with each other clearly :)

It's certainly heavily influenced by the abbreviated notion introduced by algebra (2 * x = 2x), but it is more likely supremely reinforced nowadays by fiat of computer programming languages. Most simply need to establish an order of precedence to know what to do with any complex expression. Anyone who has had a whit of programming learns this on day 1, pretty much. But that's not mathematical (i.e., able to be proven, etc.), per se, it's by design and convention.



[ Reply to This | # ]
Order of operations
Authored by: Baggins on May 25, '05 11:48:40AM

No, order of operations was not determined arbitrarily. It has to do with getting accurate answers. Since multiplication is repeated addition, it MUST be done before simple addition or you will get an incorrect answer and your bridge will collapse, your engine explode, etc.

The same is true with exponents, logs, differentials, etc. They are evaluated in a certain order because they HAVE to be in order to give the correct answer.



[ Reply to This | # ]
10.4: Be aware of a Calculator widget bug
Authored by: renderhead on May 24, '05 06:16:15PM
What everyone is ignoring here is that operations entered into the calculator app (both the stand-alone app and Dashboard widget versions) are not entered "left-to-right". They are entered "first-to-last", separated chronologically, not spatially. When you write out a problem on a piece of paper like this:

1 + 3 * 2

you are able to view the entire problem at once and determine the correct order of operations. On the other hand, what if I walked up to you and said "Quick, what's one plus three?" and then after you'd answered "4", I continued with "...times two?" How would you know if I meant 1 + 3 * 2 or (1 + 3) * 2? In that situation, you'd most likely assume the latter, and so does a calculator that shows only one value at a time.

The reason graphing calculators get it right isn't because they are more expensive. It's because you enter the entire formula, which is shown on the screen as you enter it, before you hit "equals".

[ Reply to This | # ]

10.4: Be aware of a Calculator widget bug
Authored by: tieneus on Aug 10, '05 04:01:24AM

All discussion aside. if this is a math rule OR even if it is a convention then in both instances 'every' calculator should follow this, wether convention or math rule. Because less educated people (or young children) might learn it wrong or actually think that 1+2x3=9. Imagine tax-institutions using this kind of calculus to get your tax cut (would you rather pay $7.- or $9.-) :-))



[ Reply to This | # ]
10.4: Be aware of a Calculator widget bug
Authored by: Gerk on May 24, '05 11:32:02AM

I agree with you here, it's a bug.

If you WANT incremental calculations you should type:

1 + 2 = 3
* 3 = 9

1 + 2 * 3 == 7 and it always should, the calculator shouldn't assume an = anywhere in that equation unless you specifically tell it so.

Either that or they should give the option of being fully incremental (as first example) and also the option to be algebraically correct (as in second example)... sadly I don't think most people would get it and they would still complain that it's broken LOL.



[ Reply to This | # ]
10.4: Be aware of a Calculator widget bug
Authored by: diamondsw on May 24, '05 11:57:32AM

No, this is a bug. Mathematical order of operations does not change because some insanely poorly done calculator doesn't support it, or because you don't like it. Math such as this is not open to debate or preference - it is wrong, and should be fixed.



[ Reply to This | # ]
10.4: Be aware of a Calculator widget bug
Authored by: pwagenet on May 24, '05 12:46:40PM

This is not a bug. As has been said before it behaves like all $5 calculators that calculate numbers as they are given. Cheap calculators do not remember long equation strings they only deal with opertations between two numbers at a time. When you enter this equation into a cheap calculator, it can only deal with numbers in the order that they are given so 1 + 2 = 3 then 3 x 3 = 9. This is fairly obvious and has always been the way cheap calculators work. If you want a more advanced calculator then you pay for it. Here you can just use the actual app. That said, this behavior is very easily noticed, there's no way that Apple could have accidentally missed this behavior if it was not intended.

---
-Peter



[ Reply to This | # ]
10.4: Be aware of a Calculator widget bug
Authored by: DocMan on May 24, '05 01:47:02PM

Actually with a cheap $5 calculator, you cannot enter a complex calculation and have it evaluate the entire calculation at once. Such calculators are only capable of evaluating two operands with a single operator. So it's not possible to enter 1 + 2 * 3.

Any calculator where is is possible to enter multiple operators and construct complex calculations MUST evaluate the calculation according to the established rules of mathematical heirarchy.

That said, I haven't played with the widget calculator, so I don't know which class of calculator it falls into.

Doc



[ Reply to This | # ]
10.4: Be aware of a Calculator widget bug
Authored by: sbieniek on May 24, '05 02:12:25PM

I believe it works like the old skool CPA calculators (The ones with the little receipt rolls), you have all seen them.

Anyone who has had an advanced math course will be driven batty by them, the way they make you enter complex calcuations. Basically, any time you enter a calculation, 5+5 and then hit the "*" key, it acts as an "=" key before performing your calculation. So the calculator does the math, (in this case =10, and awaits your input for the multiplication)

In this instance...the calculator is assuming you are smart enough to recognize the order of operations, and are giving the input accordingly. If you want your calculator to do more than that, then pick up a more advanced version. I believe someone has already said this widget was designed to balance your checkbook. It is truly a sad day that people need a calculator for that, but that is for another debate. I would imagine a calculator that interprets your input for you would take up far more valuable RAM than many are willing to give it...but then again, you probably need the calculator to figure out just how much RAM it would actually need. :)



[ Reply to This | # ]
To those who still think 1+2x3=9
Authored by: jlaro on Sep 27, '05 03:50:37PM

Those who think 1+2x3=9 probably hated math in school because they thought it was a purely abstract subject. Well, maths ARE the real world.

If I say: 1$ + 2 x 3$, now what? Would you pay 7$ or 9$ for those three items? 1$ + 3$ + 3$, right? "No, no" you say, "it's 1$ + 2$ x 3". Ah, you mean 1$ + 2$ + 2$ + 2$ ? How much change did you get on your 10$ bill exactly? "Ah shoot" you correct again, "I bought a one-dollar item and a two-dollar item, three times". OK I get it, like (1$ + 2$) x 3, or 3 x (1$ + 2$) or 3 x 1$ + 3 x 2$ ? (this is called distributivity) Now yes, you spent 9$, but you end up with three one-dollar items and three two-dollar items. (1 + 2) x 3 is not at all the same than 1 + 2 x 3.

Got it? Class dismissed.

Next workshop: Discovery of a basic calculator's mysterious M keys. Cost: 100 + 2 x 10 + 5. Use your preferred device to calculate and make the check payable to me.

JL



[ Reply to This | # ]
10.4: Be aware of a Calculator widget bug
Authored by: dcipjr on May 24, '05 10:52:50AM

This is exactly why I use RPN instead of standard algebraic notation.

If you want (1+2)*3, you type 1 [enter] 2 + 3 *

If you want 1+(2*3), you type 1 [enter] 2 [enter] 3 * +

It's a far superior entry system that is actually more intuitive once you get used to it. I don't understand why people insist on the old algebraic notation, with all its ambiguities. There is no order of operations (or parenthesis) in RPN, and the stack makes life so much easier.

Anyway, I digress. Apple thankfully included RPN in its Calculator app in OS X, but there is no button to let you swap the top two values in the stack, and no roll up/down buttons so that you can roll the values in the stack. That severely limits the benefits of using a stack, and I hope Apple builds in these capabilities soon.

Until then, I'll stick with my HP calculator, although the RPN Calculator Widget is a step in the right direction.

http://www.procyonit.com/widgets/rpncalc/



[ Reply to This | # ]
10.4: Be aware of a Calculator widget bug
Authored by: diamondsw on May 24, '05 11:55:01AM

Intuitive? Huh? I'll agree that it's non-ambiguous, but intuitive, no. When I see 1+2*3, I think "One plus two times three", and that's how I expect to punch it in. I do not think "One Two Three Plus Times", so RPN is not intuitive; non-ambiguous, sure, but not intuitive.



[ Reply to This | # ]
10.4: Be aware of a Calculator widget bug
Authored by: colter on May 24, '05 12:18:24PM

It's not necessarily unintuitive, it's just different from what we're taught in school. I learned RPN when I got an HP 48-GX for college, and I've never looked back. The appeal of RPN entry is that it's simpler and, as you said, not ambiguous. You first provide the data you're working with and then specify what you want done with that data. It comes down to personal preference; I think it's easier to work in RPN.

You're doing the same thing, whether it's written as infix or postfix notation. One way, you learn to resolve operations in PEMDAS order. The RPN way, you learn to do it as you go.



[ Reply to This | # ]
10.4: Be aware of a Calculator widget bug
Authored by: gleam on May 24, '05 01:21:52PM

Actually, in RPN, if you wanted to do 1+2*3 you would do 1 2 3 * +.

Well, I would do 2 3 * 1 +, but that's me.

I don't think either is more or less intuitive. You think 1+2*3 is more intuitive because you grew up seeing it written out as 1+2*3. If you'd seen it written out 1 2 3 * +, you'd think RPN was intuitive. It's all stuff you learned at some point, you didn't innately know that + meant plus, for instance.

Anyway, on calculators the big advantage of RPN is that it saves you keystrokes.

An example:

you want to calculate ((2*8)+(9*3))/((1/7)-(5*9))

That's pretty much how you have to write it on most non-rpn calculators. you might be able to eliminate a parenthesis or something, but otherwise you're left to type in all that crap.

RPN: 2 8 * 9 3 * + 1 7 / 5 9 * - /

14 keystrokes vs 28. As the complexity increases so, generally, do the savings from using RPN.




[ Reply to This | # ]
10.4: Be aware of a Calculator widget bug
Authored by: jlaro on Sep 30, '05 09:07:32PM

Actually, it's 19 vs 19 keystrokes, not 14 vs 28. For the RPN you forgot to count the ENTERs between values (otherwise 2 8 is 28), and for non-RPN there were too many parenthesis as you said (and the last one can be dropped because = closes it automatically).

I admit, I never used an RPN calculator before writing this post. The big difference seems to be that with RPN you have to memorize which groupings interact with which, and how, to put operations at the right place, whereas with the normal method the machine does it for you if you follow exactly the written equation (with SOMETIMES extra parenthesis to make sure the machine understands correctly).

Question to RPN experts, how would you enter the quadratic solutions (-b+SQRT(b^2-4ac))/2a and (-b-SQRT(b^2-4ac))/2a ? I tend to think that a lot of memorizing is necessary.
24-keystroke non-RPN example: ( - 2 + ( 2 x2 - 4 * 3 ± * 8 ) SQRT ) / ( 2 * 3 ± =

I guess it's just like reading sheet music, anybody can get used to anything.

(somehow ± can be shown here, but not the square root sign, hence my use of SQRT)



[ Reply to This | # ]
"Intuitive"
Authored by: MJCube on May 24, '05 03:17:54PM

"more intuitive once you get used to it" is a contradiction. To me 'intuitive' applied to software means it works the way you expect the very first time, and you don't have to get used to anything.



[ Reply to This | # ]
"Intuitive"
Authored by: raider on May 26, '05 09:28:24AM

Exactly. Freaking "rocket science" is intuitive if you are a rocket scientist...

I have been using a mouse for almost 20 years now, and I can't imagine anything simpler. But the mouse confused the heck out of my 70 year old stepmom who had never touched a computer (not even an ATM) in her life... She would lift the mouse up off the table to move the cursor up. To her - UP was UP! Not Up was Forward....

It is all relative.

I say that RPN is annoying as hell. So I don't use it. That is the beauty of our world. We use what we want... I would rather use the 28 keystrokes and make something that looks usable than use less and make it cryptic and confusing to 90% of the people who look at it... But if RPN is nice for you, by all means - use it...

Just like the two button mouse.
(ducking...)



[ Reply to This | # ]
10.4: Be aware of a Calculator widget bug
Authored by: mcroft on May 24, '05 11:14:48AM

Well, it's just javascript. I'm at work and can't mess with the source, but it may not be too hard to modify.

Of course the other possibility is that becuase of how they implemented the JS, it's unfixable and would need a re-write.

Anyone looked under the hood?



[ Reply to This | # ]
10.4: Be aware of a Calculator widget bug
Authored by: Spartacus on May 24, '05 11:49:08AM
Well, it's just javascript. I'm at work and can't mess with the source, but it may not be too hard to modify.

It will probably be harder than you think.



[ Reply to This | # ]
Implementing PEMDAS
Authored by: colter on May 24, '05 12:28:24PM

Probably harder than you think.

I agree. As the user enters numbers and operators, you've got to keep track of what's been entered and what's okay to calculate now. With left-to-right entry and evaluation, you can evaluate expressions as the user enters them. This is probably why Apple went with LTR over PEMDAS -- it's easier to implement.

To implement PEMDAS, you really need to have parenthesis available, or you're not able to use the intermediate result of a lower-order calculation as an operand to a higher-order calculation. For example, 2 * (1 + 3) or 3 ^ (4 - 1). Actually, I'm not sure you can do those with LTR, either, without parenthesis. This is where postfix evaluation comes in so handy. :) 2 1 3 + * and 3 4 1 - ^ and you're done. ;)



[ Reply to This | # ]
Implementing PEMDAS
Authored by: mcroft on May 24, '05 08:29:14PM

Not really, all you're doing is building a string to send to the JavaScript eval() function. The engine handles PEMDAS just fine and since there aren't buttons for P and E, it's limited right now to the rather simple MDAS.

I've got it working for addition right now. I need to make it smart enough to not add a second operator if the last item is already an operator. Once it's working, I need to add a preference [Delayed Execution/Immediate Execution], a flip to the backside button and a backside, and then let some of you test it.



[ Reply to This | # ]
Implementing PEMDAS
Authored by: mcroft on May 24, '05 10:06:31PM

I've got the JavaScript done for a drop-in replacement if anyone wants it. I'll start messing with a polished implementation with a setting on the back et. al., but I've done a lot more JavaScript than I have widget work, so I don't know when it will be done.

powers are more difficult, but not out of the question (eval won't handle them intrinsically).

email me and I'll send you the modified calculator.js.

It's also pretty clear how you'd use this for RPN



[ Reply to This | # ]
Implementing PEMDAS
Authored by: mcroft on May 25, '05 01:15:48AM
Option Enabled MDAS awareCalculator Widget variant.

[ Reply to This | # ]
10.4: Be aware of a Calculator widget bug
Authored by: cujo on May 24, '05 11:46:51AM

This is not a bug! You don't type 1+2*3 into a single screen on the calc widget. Every time you hit an operator (+,*,-,/, etc) it evaluates the arguments.

This is not complicated. Go pick up any calculator and hit 1+2 and then *. The screen will display 3. Then when you type 3, it multiplies 3*3. This is correct!

It has been said before, but the way calculator.app handles this is misleading and not what the average joe who picks up a standard calculator would expect.



[ Reply to This | # ]
10.4: Be aware of a Calculator widget bug
Authored by: diamondsw on May 24, '05 12:02:59PM

On all three of my calculators, it properly obeys the order of operations, regardless of what the display shows, which is correct.

This will be my third post saying it - mathematics is not open to your personal preference. It is a very exact discipline, and you are wrong. Find a mathematician (or a third grade teacher - that is when we learned this, after all) and have them explain it to you, if you still think left to right is in any way "correct".



[ Reply to This | # ]
10.4: Be aware of a Calculator widget bug
Authored by: sdewidt on May 24, '05 01:23:57PM

I think everyone agrees with you on the order of operations. Everyone know "Please excuse my dear aunt sally" or however you learned to remember it. But, I think there are different types of calculators that do things a little differently. I'm, unfortunately, in front of a windows machine right now and I checked out the calc app that is on this machine. Using it in standard mode and typing in the numbers gives me 9, but when I switch it to scientific mode I get 7. I think the calc widget is mimicking one of those cheap calculators that is doing the math step by step instead of considering the numbers as on continuous argument. On those calculators, any time you hit an operator sign, it uses the answer from the step before. In other words, when you type in 1 + 2 and then hit * 3, what the calculator is actually doing it 1 + 2 = 3 * 3 = 9. In my experience this is how most cheap calculators work. I've used a Ti-83 for the last 8-10 years, so I'm just used to typing in all of the numbers on one line and then hitting enter. Anyway, I hope this clears up any problems and misunderstandings.



[ Reply to This | # ]
10.4: Be aware of a Calculator widget bug
Authored by: csherrera on May 24, '05 02:13:22PM

Look, the calculators you own are obviously designed more recently - I suspect they are scientific or student calculators that understand precedence.

I can't believe how young everyone is on this forum. Am I the only one who remembers that the "cheap, $5 calculators" everyone talks about used to be the $100 calculators not 30 years ago?

When I went to school, precedence was taught as something that you - the mathematician used. It was not something that a calculator figured out for you. If you were presented with the statement 1+2*3= it was up to you to type 2*3+1 to get the correct answer on the calculator. When you did the same calculation on a sliderule, again, you had to do it in the right order.

Look, there is a history to this, these simple calculators follow that historical norm. Just because more modern calculators are smarter, shouldn't obviate the need for YOU to be smart about how you use a tool. Jeez.



[ Reply to This | # ]
10.4: Be aware of a Calculator widget bug
Authored by: Ol' Codger on May 24, '05 05:28:31PM

You're so right old fellow! These young whippersnappers just don't understand that it's up to them to get it right! Actually the rules they cite, taught to them in the third grade, were intended to teach them how to simplify an arithemetic equation in a multi-step fassion and do not apply to a binary operation calculator. Evaluate everything within parentheses first and rewrite the simplified equation, apply exponents and rewrite the equation, etc.

The common binary operation calculator is only intended to return a result of a binary operation. Given a new operator followed by a operand (number) followed by another operator will generate a new result and allow for chaining calculations in the order they are fed to the calculator, but this in not a strict application of PEMDAS. Then there is RPN which is another beast alltogether.

I'm amused at the author's conviction of the rightness of his assertion. I suggest he not be so adamant and learn how to utilize the tool at hand, or ... get a tool of his liking.



[ Reply to This | # ]
10.4: Be aware of a Calculator widget bug
Authored by: PeteVerdon on May 24, '05 06:08:16PM

That's what it is!

I definitely fall into the "young" camp as per your "$5 calculator" argument, but the standard calculator at school did operations one at a time like the Dashboard widget. I'm well used to this and, as you say, know what order to put things into it to get the right answer.

On coming to University, my department required that everyone use a *different* "standard" calculator in exams. (No hardship; they sell them for £6 or so). This one has what seems to me a very wierd input system, where you enter the expression and it appears on a series of dot-matrix cells above the main number area, until you press equals and get the answer. I find this awkward to use, wondered why on earth it did that, and generally do one operation at a time as before. But having read this thread I now understand why it's like that - it's trying to do precedence for me, just like it seems other people here are used to. Makes sense, but I still don't like it.

Pete



[ Reply to This | # ]
10.4: Be aware of a Calculator widget bug
Authored by: itcomesinwaves on May 24, '05 09:28:45PM

"This will be my third post saying it"

..and this is the third time I've cringed reading it. You clearly have missed the point:

- the widget emulates a cheap, non-scientific calculator
- these type of calculators can NOT perform more than one operation at a time
-- (when you press an operator key, it totals the previous operation.)
- this absolves the calculator of any responsibility to obey 'order of operations' because it can only evaluate ONE operation at a time. The responsibility rests with the user to use this "one-operation-at-a-time' tool properly. The order of operations remains unchanged, the calculator works as it is meant to (I.e., with limited scope).


Do you understand now?



[ Reply to This | # ]
10.4: Be aware of a Calculator widget bug
Authored by: starwxrwx on May 26, '05 02:46:45AM

It's not strictly a bug, but it is a very poor decision by Apple.

Cheap, crappy calculators should be outlawed.

Any decent calculator gets the order of operation correct (which, by the way, is called BIMDAS here in Australia). You should not have to think about the order of operation before typing in your calculation.

Anyone who defends a calculator not doing its job properly (and hence has not passed primary school maths) is not qualified to enter the debate in the first place.



[ Reply to This | # ]
10.4: Be aware of a Calculator widget bug
Authored by: pantera on May 24, '05 12:02:21PM

As others have pointed out, this clearly is not a bug. The calculator widget both visually and in its behaviour is a simple step-by-step calculator.

If you want to enter complete formulae (with parentheses, and the usual operator precedence) you can use FormulaCalc. As mentioned earlier, using RPN notation with "RPN calculator" is a viable alternative.

I find the interface of the calculator app in Tiger to be rather bad, as there is no clear visual feedback to the fact that it is evaluating a complete formula, and not doing step-by-step processing. Calculators behaving that way usually have an entry line showing what you have typed so far, which calculator.app is lacking. Only the paper tape shows you (afterwards) what has actually been done. This is particularly inconsistent with the fact that the basic interface has no parentheses.



[ Reply to This | # ]
10.4: Be aware of a Calculator widget bug
Authored by: diamondsw on May 24, '05 12:17:17PM

As I have consistently pointed out, this is most certainly a bug. Math doesn't change because developers are lazy. Now, if they want to clean up the interface, I'm all for that, but left to right is not correct under any circumstances.



[ Reply to This | # ]
10.4: Be aware of a Calculator widget bug
Authored by: pwagenet on May 24, '05 12:50:04PM

No one is claiming that math changed. All that is being said here is that the calculator is just calculating one operation at a time. This is standard and expected behavior of calculators of this sort. The only non-graphing calculator I have ever seen that used order of operations was one with advanced features like parenthases.

---
-Peter



[ Reply to This | # ]
10.4: Be aware of a Calculator widget bug
Authored by: starwxrwx on May 26, '05 02:49:52AM

Standard scientific calculators you get in year 8 use BIMDAS.



[ Reply to This | # ]
10.4: Be aware of a Calculator widget bug
Authored by: diamondsw on May 24, '05 12:04:12PM

Have you reported this as a bug in Apple's RADAR system? If not, I'll be glad to.



[ Reply to This | # ]
10.4: Be aware of a Calculator widget bug
Authored by: rhowell on May 24, '05 12:45:58PM

No, I have not. If you could that would be great. Thanks for sticking to your guns in the posts above :)



[ Reply to This | # ]
10.4: Be aware of a Calculator widget bug
Authored by: krove on May 24, '05 01:41:13PM

This discussion, while fervent, is pure semantics: bug versus not a bug. It is quite amusing to see how worked up both sides are in arguing their points. Here's what it boils down to:

  1. Order of operations are not being taken into account.
  2. Nearly *ALL* simple, cheapo calculators that this widget emulates do not understand or adhere to order of operations.
  3. Nicer calculators (usually ones with a few or more scientific functions) certainly do understand order of operations.

Now, this discrepancy (left out feature, whatever) on the part of Apple certainly could be improved in the future. But if they didn't: it really doesn't matter because it is a dumb calculator just by its looks, and as such, falls clearly inline with number 2 in my short list above.



[ Reply to This | # ]
FWIW...
Authored by: MattHaffner on May 24, '05 01:56:24PM

Until Panther or so, going back as far as I remember using a Mac (Finder 4.1 or something), the calculator desk accessory/app has *always* done math this way. No, it's not how many of us (even slightly) tech-inclined like a calc to work, but at least it's historically accurate :)



[ Reply to This | # ]
10.4: Be aware of a Calculator widget bug
Authored by: szabesz on May 25, '05 09:21:44AM

" it really doesn't matter because it is a dumb calculator just by its looks"
I STRONGLY agree! I am never going to use it! There are lots of other and better freeware alternatives around. Why should we bother at all? :)



[ Reply to This | # ]
Get the correct answer with paste
Authored by: jctull on May 24, '05 01:56:37PM

If you want the correct handling of operations, copy your calculation sequence, e.g., 1 + 2 * 3, and paste this into the widget screen (works for calculator.app as well). You will get the correct result, 7.

As others stated, the widget behaves like a cheap calculator that assumes you want an intermediate result when you enter items individually. But if you paste a more complex calculations, the order of operations is handled correctly. Works for me.



[ Reply to This | # ]
Get the correct answer with paste
Authored by: itcomesinwaves on May 24, '05 09:30:41PM

Awesome! This is the real hint right here!



[ Reply to This | # ]
10.4: Be aware of a Calculator widget bug
Authored by: justice on May 24, '05 02:52:57PM

I'm not replying to any one specific post because there are about 10 places where I could jump in with this, and I couldn't pick just one of them.

I'm a mathematician. Pursuing a PhD in mathematics at Georgia Tech, to be more precise. As someone so nicely pointed out, the order of operations is merely a convention. We mathematicians like our conventions, becuase they're the only way that we can communicate clearly in writing. A convention is just that. It cannot be "right" or "wrong". In fact, in advanced, cutting-edge mathematics (yes, it does exist, and it's not adding and multiplying even bigger numbers), there are often competing conventions for things until a field is well-developed enough that a standard emerges. The convention for order of arithmetical operations exists simply so that we do not have to fully-parenthesize every single arithmetical expression.

As far as the debate on if this is a bug or not, I will not call the widget's behavior a bug. It is a horrible inconsistency that Calculator.app and the calculator widget return different answers in response to the same sequence of keypresses. However, I have yet to meet a simple, four-function calculator (meaning can only do addition, subtraction, multiplication, division as arithmetic operations) other than Calculator.app that observes the order of operations. (Please don't tell me that you have one that does sitting on your desk. I'm not saying they don't exist, just that I've never seen one.) Four-function calculators that most people are familiar with behave incrementally, and thus update the display with the result every time a new operation key is pressed. I think the widget behaves in the way that most people would expect a calculator of its appearance to behave.

I believe that Calculator.app behaves improperly in Basic mode, as it doesn't provide sufficient feedback that it is storing up the entire string of symbols entered until you ask for an answer. It looks like a brain-dead, four-function calculator, and thus it would probably be better if it behaved like one. When I switch to scientific mode, I expect it to behave like a scientific calculator, which would mean that it will respect the conventional order of operations. Another poster put it very well when he said that you should use the right tool for the job. If you want to just do some quick arithmetic, you're probably not thinking about order of operations and want things evaluated in the order entered. If you're performing a calculation where you've put in enough thought to have constructed something where you want to enter it as it's written (using the conventional order of operations) and want to have it evaluated following the order of operations, you're not going to use a four-function calculator without carefully thinking about how to enter things.

If you take anything away from this post, it should be two things. First, that the order of operations is a convention for writing down arithmetical expressions. It happens to have been adopted by scientific and graphic calculators as well as programming languages because that's the convention that people were familiar with, but it's essentially about writing down strings of symbols so that there's a well-defined way to evaluate them. Second, I used the words "believe" and "think" a lot in this post. That's because this is an area where it's all based on opinions. It's probably good that this hint was posted, because it made a lot of people aware of the fact that Calculator.app and the calculator widget give different answers when presented with the same key sequence. There's not right answer other than to use the tool that does what you want it to do.



[ Reply to This | # ]
10.4: Be aware of a Calculator widget bug
Authored by: Makosuke on May 24, '05 06:13:11PM

Glad that somebody explained what I was going to say clearly. It is what it is, and that's the way it behaves. If anything, the basic mode in newer versions of Calculator.app behaves in the less-expected manner.

Additional, UI thoughts:

For one thing, a basic "dumb" (meaning four-function, non-scientific, like the Widget) calculator has no parentheses keys, so you can't type in a lot of equations without breaking them down mentally and hitting enter a lot. This is a big reason to remove the order of operations completely and just operate on the previous two entered values.

An additional good reason to limit four-function calculators to a single thread of logic: If you don't do this, there is absolutely no visual feedback as to the equation you've entered, and as such no way to visually verify what the heck you're doing.

Example: If I type 1 + 2 * 3 - 4 / 5 into a scientific calculator, I should see exactly that (as, for example, the tape in Calculator.app shows). If I type that into a dumb calculator, I'd have no confirmation what I typed, either as I'm typing it or afterward--all I see is an answer.

As such, it's clearer from a UI perspective to, once I type 1+2*, have the calculator display the result of that operation, 3, illustrating what I'm about to operate on next, and so on.



[ Reply to This | # ]
10.4: Be aware of a Calculator widget bug
Authored by: chyna4xena on May 24, '05 10:43:10PM
It is nonsense to suggest that the implied order of operations "cannot be right or wrong" - it is right, in the sense that failing to adhere to it will give you the wrong results.

People writing equations are always going to follow the rules, because there are no other alternative "conventions". If there is only one "convention", and it must be followed for accuracy, then it is not a convention at all, but a rule.

If you receive the equation a + b * c, then the correct formula is a + (b * c) because the person writing the equation would have written (a + b) * c if they had meant it to be computed that way. They are not going to think "well, under a different convention, a + b * c does equal (a + b) * c, so its OK to leave it un-parenthesised when what I mean is (a + b) * c".

You said it yourself: "there are often competing conventions for things until a field is well-developed enough that a standard emerges" (my emphasis). The field of arithmetic is indeed well developed, and the implied order of operator precedence is indeed a standard.

And, for reference, scientific and graphical calculators, along with programming languages, did not adopt any mathematical "conventions". They adopted a rule which was already (long, long already) a standard, and they had no choice but to do that. The notion that they arbitrarily chose from amongst a selection of possible implied orders of operation is just plain wrong.

As for the calculator widget, I would not call its behaviour a bug - because the behaviour is clearly intended, and it is correctly re-creating the behaviour of the device it is emulating. A calculator that can only handle dual-operand operations isn't buggy or wrong (it correctly calculates those dual-operand operations), just feature-poor.


[ Reply to This | # ]
10.4: Be aware of a Calculator widget bug
Authored by: thelamecamel on May 25, '05 05:06:12AM

I am most of the way through a 2nd year university course that deals with defining and constructing numbers, addition, multiplication etc. Our PEMDAS convention could have easily been different (say PEASDM), in which case you would get 1+2*3=9.

Of course, we do use PEMDAS when we normally write equations, so if I wrote down 1+2*3, it should be evaluated as 7.

BUT, THIS CONVENTION ONLY HOLDS FOR WRITTEN FORMULAE - there are no axioms about pocket calculators!

Whoever built the first pocket calculator established a new convention for inputting equations, which is sometimes more useful, and often less useful. This convention was established presumably because calculators originally could not handle PEMDAS. The Dashboard widget, as others have remarked, is meant to simulate a cheap, pocket calculator. It is not a scientific calculator.

Written arithmetic is a slightly different language to what you type into a calculator - even a scientific calculator (Would you ever write 4^2 on paper?). Making the languages as similar as possible is useful for people who have written down, mathematically formatted equations to evaluate. But when i'm working out what I want to do as I go along, the pocket calculator arithmetic language is often more useful to me.

The other problem with observing PEMDAS, as highlighted above is that it's mighty confusing without a visible record of what you've typed so far, which would really complicate the widget.

Widgets are fast access programs that you want to use briefly. Whenever i want to make a quick calculation, pocket-style calculators are faster and easier to use. If I want PEMDAS, then i'm doing something more complex, and chances are i'll be evaluating a whole bunch of equations and so would be better served by a proper application.



[ Reply to This | # ]
10.4: Be aware of a Calculator widget bug
Authored by: chyna4xena on Oct 25, '06 06:51:56PM

quote - "Whoever built the first pocket calculator established a new convention for inputting equations, which is sometimes more useful, and often less useful. This convention was established presumably because calculators originally could not handle PEMDAS"

That is not correct.

The first pocket calculators (and cheap ones since) did not establish a new convention for inputting equations at all. They only performed operations on two operands at a time (without exception, this is all that they do) so there was no 'convention' needed about inputting formulae! PEMDAS conventions, etc, have no relevance whatsoever to dual-operand instructions.

That is the point that has been continually missed throughout this discussion - a dual-operand calculator and PEMDAS have [b]nothing[/b] to do with each other.

Then they made calculators which could handle multiple-operand instructions (ie 'equations' or 'formulae'), and at this time, they adhered to the ONLY rule that has ever been accepted for determining the order of operation - PEMDAS.

You say that there are "no axioms about pocket calculators" when you should say, "there are no [b]specific[/b] axioms about pocket calculators because of course they would obey the same rules that everyone else, and everything else, is obeying."

quote - "Written arithmetic is a slightly different language to what you type into a calculator - even a scientific calculator (Would you ever write 4^2 on paper?)."

That is a furphy. The difference between "4^2" and a "4" with a superscripted "2" is zero - there is no difference between them. They are the same number ... 16.

The written language of arithmetic, and the language of scientific calculators, is identical, because scientific calculators were specifically designed to correctly calculate the written language of arithmetic, and they were specifically designed to obey PEMDAS in multi-operand equations.



[ Reply to This | # ]
'tsall good.
Authored by: samsprograms on May 24, '05 03:35:43PM

I think the solution to this is just to allow the user to flip the widget and choose which way he or she wants to use. I do think that the basic way is the correct way, but if you allow the user to choose everyone will be happy. YAY!



[ Reply to This | # ]
10.4: Be aware of a Calculator widget bug
Authored by: Alejandra on May 24, '05 06:29:55PM

I agree with you, its a calculator not a FORMULA solver.



---
Ciao,
Alejandra.



[ Reply to This | # ]
10.4: Be aware of a Calculator widget bug
Authored by: Anidel on May 24, '05 07:00:24PM

By the way.. check also the Help for Calculator.
It clearly states the order of operations:

"Calculator performs operations in a specific order, which can affect the result of your calculations. For example, 1+1x2 returns a value of 3 since Calculator evaluates operations involving multiplication (1x2) before operations involving addition (+1)."

and from: "The results of my calculations aren't correct" help:

"Operations are calculated differently than you expect. When performing calculations, Calculator uses the Fundamental Order of Operations to evaluate expressions. For example, multiplication operations are completed before addition and subtraction.

If you're using the programmer's calculator, values may not be displayed in the format you expected. Use the buttons marked Hex, Oct, and Dec to choose the correct format.

You may have entered the calculation incorrectly. Choose View > Show Paper Tape to review what you entered."

---
Anidel



[ Reply to This | # ]
10.4: Be aware of a Calculator widget bug
Authored by: zane on May 24, '05 07:25:37PM
When I discovered many moons ago, that Google can act as a formidable scientific calculator, following the standard PEMDAS routine, I pretty much forgot about every other Calculator that existed. Try "1+2*3" in Google and you of course get the correct "7" result. Google even adds parentheses on it's results page showing how your formula should be formatted correctly, which is great for education!

Since Safari is generally running on my computer 24/7, the Google search box has pretty much become my full-time calculator (and unit converter, spell checker, dictionary... well, CTRL-CMD-D plays the Dictionary role now, but I digress :P).

[ Reply to This | # ]
10.4: Be aware of a Calculator widget bug
Authored by: coolsoldier on May 24, '05 10:27:36PM

I have to side with the "not a bug" camp on this one. The dashboard widget displays a non-scientific, four-function calculator.

Since non-scientific, four-function calculators almost always evaluate operations in sequence, the calculator is behaving exactly the way most regular users of non-scientific, four-function calculators would expect.

Acting the way most users would expect is not a bug.



[ Reply to This | # ]
10.4: Be aware of a Calculator widget bug
Authored by: RobertBen on May 25, '05 07:27:08AM

And Apple gives us the full featured calculator for people that want to the scientific approach and the widget-calculator for non-scientific approach, makes sense to me...



[ Reply to This | # ]
Not a trivial fix + it's not a calculator, it's an adding machine
Authored by: Gerk on May 25, '05 12:28:19PM
So to everyone that's whining about this, the way it behaves right now it it NOT a calculator, it's an 'adding machine', plain and simple. For everyone comparing it to $5 calculators .. they are not calculators either then, they are also adding machines. The cost of the calculator should not determine whether it obeys the laws of mathematics or not.

So here's their methods for doing the actual work, and as you can see it's not a trivial fix to make it work properly LOL


function add() {
	a = evaluator(a+"+"+x);
}

function sub() {
	a = evaluator(a+"-"+x);
}

function mult() {
	a = evaluator(a+"*"+x);
}

function div() {
	a = evaluator(a+"/"+x);
}

They need to rewrite a big piece of it (while they are at it they should just replace the whole thing, it's pretty messy). They should be keeping a running 'equation' in the process and not just blindly doing what they are doing above. To work like a real calculator it should evaluate this running equation at each step and report this back to the output display ...

It's not rocket science (or is it? this thread makes me wonder LOL). Let's just say that whoever wrote this 'calculator' widget wouldn't make it onto my development team, paid or not!

[ Reply to This | # ]

Not a trivial fix + it's not a calculator, it's an adding machine
Authored by: Gerk on May 25, '05 12:31:02PM

incidentally is it just me, or is dashboard/widget combo just a security breach waiting to happen? And I don't mean just in the malicious widget front ... I mean you are getting a lot of access here, and for some reason I suspect that there are many things that a crafty coder can take advantage of here . . .

Some may call me paranoid, but ... I prefer to call myself a realist.



[ Reply to This | # ]
Yes it is a trivial fix
Authored by: mcroft on May 25, '05 01:05:04PM
Yes, it's a trivial fix.

I wrote this after work last night. Here you go. It works both ways and has a persistant preference to let you pick which you want.

The reason it's a trivial fix is the same reason that pasting "1+2*3" calculates properly. The basic resolver is eval(display). As long as you build a string, it can resolve it.

[ Reply to This | # ]

Yes it is a trivial fix
Authored by: Gerk on May 25, '05 04:31:38PM

"Trivial fix" and "Easy Fix" are 2 different things ... it was an "easy fix" because you did it correctly by keeping a running tally of the equation. I don't consider a 400 line diff trivial considering it was a 540 line javascript to start with ;) hehe .. it's all relative!



[ Reply to This | # ]
OK, it's an easy fix
Authored by: mcroft on May 25, '05 05:05:20PM

Yeah, well. Calculator.js was as small as it was before because it didn't have an info button and backside and those require a lot of new functions to be copied and pasted from the documentation.

Anyway, the processing is easier than the processing that's being done to provide immediate evaluation.

The sub/add/mult/div functions are way too repetitive, as well. If I find any reason to touch it again, I'll fix that.



[ Reply to This | # ]
More on why it's a trivial fix
Authored by: mcroft on May 25, '05 01:23:37PM
The key here isn't to change the add/sub/mult/div methods, but to intercept the keydown and add it to the display string.

This is how I handled the add key in the variant I posted. deferredEvaluation is a variable I set at startup to tell me which file to process. OpList is a list of operators that can't be entered twice (no "9++4"). The final "else" is the prior "case add" code to call function add if deferredEvaluation is false.

It took me more time to work through making and saving a preference, a back, flipping the app, etc., than it did to update the JavaScript.


var deferredEvaluation = true;
var OpList="^!()+-*/";
{...}
case "add":
if (deferredEvaluation) {		
    if (!display.length) {
        clearDisplay();
        break;
    };
    if (OpList.indexOf(display.substr(display.length-1,1)) != -1 ) {
        display = display.substr(0,display.length-1)
   };			
   if (display.length < 9)
        display = display + "+";
   break;
} else {
    if (a && !isResult && !resetDisplay) {
        performOp();
    } else {
        a = evaluator(display);
        isResult = false;
    }
    currentOp = buttonTitle;
    hiliteOp = buttonTitle;
    resetDisplay = true;
    break;
}


[ Reply to This | # ]
10.4: Be aware of a Calculator widget bug
Authored by: samsprograms on May 25, '05 04:30:11PM

Whatever happens, I hope that Apple doesn't make it use the order-of-operation way of doing things. When I am using a calculator that displays things the way this one does, I expect it to do things in the order I enter them. You aren't supposed to need to think about the order of operations whenever you are only doing simple calculations.



[ Reply to This | # ]
10.4: Be aware of a Calculator widget bug
Authored by: starwxrwx on May 26, '05 02:56:39AM

"You aren't supposed to need to think about the order of operations whenever you are only doing simple calculations."

What you say is correct - it should do BIMDAS (or PEMDAS as above) and that should be it.

You shouldn't have to think 'oh no, first I have to work out what 5 times x is, then I have to add it to y and... yikes, I didn't work out 6 times z in advance, back to the beginning!' - you should just type in your expression the same way you learnt to calculate IN PRIMARY SCHOOL

Anyone who missed this basic concept should not be allowed near a calculator!



[ Reply to This | # ]
10.4: Be aware of a Calculator widget bug
Authored by: rathinam on Jun 04, '05 03:01:56PM

Whether bug are feature, the problem is really that this is inconsistent with the way the Calculator Application works (the App gives the answer 7). The dashboard widget should work the same way.



[ Reply to This | # ]