The Museum of HP Calculators

HP Forum Archive 15

[ Return to Index | Top of Index ]

HP48g - Arithmetic Rounding querry
Message #1 Posted by Caribe T on 7 Nov 2005, 7:40 a.m.

I am sure there is a reason for this explained somewhere in the manual, but I am hoping that someone knows the answer off the top of their head. As an example,why is it that I get the following - equating: '5/3' (or 3, 'SPC', 5, /) = 1.66666666667 (which gives me '5/3' if i put it back as a fraction.

But if I do '5*(1/3)' (or 5,'SPC', 3, '1/x', x) = 1.66666666666 (which gives me '62500000003/37500000002' as a fraction; which is of course the exact solution of the 1.66...6 solution).

How do I prevent getting the second answer?(other than just by entering the equation in using the first method). Reason that I ask is that during exams I don't want to have to be always worrying about what format I should be entering the problem (so as to not get a large fraction as above.) I am supposing that there is a setting that I may need to change. Can anyone point me in the right direction here? Thanks

      
Re: HP48g - Arithmetic Rounding querry
Message #2 Posted by Arnaud Amiel on 7 Nov 2005, 8:49 a.m.,
in response to message #1 by Caribe T

My 48 ran out of batteries but my 49 suggests that using ->QPi (where Pi is the greek letter) should help.

Or if you have a connection cable you should try: QPI from hpcalc.org

Arnaud

Edited: 7 Nov 2005, 9:04 a.m.

      
Re: HP48g - Arithmetic Rounding querry
Message #3 Posted by Chris Dean on 7 Nov 2005, 11:14 a.m.,
in response to message #1 by Caribe T

I would hazzard a guess that it is to do with the order that the expression is calculated.

5 * (1 / 3) = 5 * (0.333333333....) = 1.666666666666......5 and rounded 1.666666666666....6

5 / 3 = 1.666666666666666666666.........6 and rounded 1.6666666666666666...7

You can replicate this problem with any calculator.

Edited: 7 Nov 2005, 11:37 a.m.

            
Re: HP48g - Arithmetic Rounding querry
Message #4 Posted by Tom Steiner on 7 Nov 2005, 2:13 p.m.,
in response to message #3 by Chris Dean

That would have been my guess as well. But my 12C Platinum calculates 1.666666667 either way.

                  
Re: HP48g - Arithmetic Rounding PROBLEM?
Message #5 Posted by Caribe T on 7 Nov 2005, 2:57 p.m.,
in response to message #4 by Tom Steiner

Yeah my Casio gives the me correct fraction regardless of how I enter it......

What confuses me again is this: '2/3' = 0.666666666667 (which in turn gives me '2/3' as a fraction.

But if I do '2(1/3)' = 0.6666666666666 - this gives me '2/3' as a fraction.

Can anyone figure out the inconsistency from this and the initial problem I mentioned?

Edited: 7 Nov 2005, 3:48 p.m.

                  
Re: HP48g - Arithmetic Rounding querry
Message #6 Posted by Gunnar Degnbol on 7 Nov 2005, 5:30 p.m.,
in response to message #4 by Tom Steiner

Quote:
That would have been my guess as well. But my 12C Platinum calculates 1.666666667 either way.

It depends on the rounding. 0.33...333 * 5 is 1.66...665. This is one digit too much, so the final 5 has to be either truncated or rounded. ...665 is right between ...660 and ...670, and there are different methods in use. Half-up always rounds 5 up, and so the result is ...67. Half-even (sometimes called banker's rounding) rounds fives to the nearest even digit, which in this case is 6.

The advantage of half-even rounding is that it gives a better statistical distribution of errors, because 5 really is right between 0 and 10, and always rounding up isn't fair.

                        
This makes interesting reading (includes code)
Message #7 Posted by Valentin Albillo on 8 Nov 2005, 10:55 a.m.,
in response to message #6 by Gunnar Degnbol

Hi, Gunnar:

This link features an interesting and worthwhile discussion on rounding, and includes simple code to implement most usual rounding strategies.

Best regards from V.

                              
Re: This makes interesting reading (includes code)
Message #8 Posted by Gunnar Degnbol on 8 Nov 2005, 3:09 p.m.,
in response to message #7 by Valentin Albillo

Thank you, It is very interesting.

I knew about the difference between VBA and Excel, but I was not aware that they had such a mess across their product line, and I had not noticed that Java had a homebrew not-seen-anywhere-else round() function.

Mike Cowlishaw's General Decimal Arithmetic Specification has a list of all the rounding modes you may need when things are actually designed, and not just happens.

This is a superset of the modes described in the IEEE 854 standard, and implemented in the HP 71B.

He has the following note:

Quote:
The term ‘round to nearest’ is not used because it is ambiguous. round-half-up is the usual round-to-nearest algorithm used in European countries, in international financial dealings, and in the USA for tax calculations. round-half-even is often used for other applications in the USA, where it is usually called ‘round to nearest’ and is sometimes called ‘banker’s rounding’.

                        
Re: HP48g - Arithmetic Rounding querry
Message #9 Posted by J-F Garnier on 8 Nov 2005, 3:16 p.m.,
in response to message #6 by Gunnar Degnbol

Another example of half-even rounding (in Saturn-based HP calculators):
1E12 1 - 2 / gives 500000000000 (rounded up from 499999999999.5)
1E12 3 - 2 / gives 499999999998 (rounded down from 499999999998.5)

J-F

      
Re: HP48g - Arithmetic Rounding querry
Message #10 Posted by guest on 7 Nov 2005, 7:54 p.m.,
in response to message #1 by Caribe T

I stumbled across the solution to this recently. Just change the display mode to FIX.

            
Re: HP48g - Arithmetic Rounding querry - PROBLEM SOLVED! But any more ways?
Message #11 Posted by Caribe T on 7 Nov 2005, 8:14 p.m.,
in response to message #10 by guest

Hey thanks for that.....It seems to solve the problem! Genius!

However is there another way of doing this (so you don't have all these decimal places after a whole number for example.(like having just '3' on the stack and not '3.00000000...', depending on what FIX number you set)?

Edited: 7 Nov 2005, 9:24 p.m.


[ Return to Index | Top of Index ]

Go back to the main exhibit hall