The Museum of HP Calculators

HP Forum Archive 19

[ Return to Index | Top of Index ]

OT: basic arithmetic functions
Message #1 Posted by Thomas Klemm on 10 Dec 2009, 8:44 p.m.

Recently I purchased a new mobile phone (SAMSUNG SGH-C180) and as always I was curious about the features of the calculator. The manual was short with the description:

Quote:
Perform basic arithmetic functions.

Here's the menu:

*   .
#   + - x / % ( )

Just an ordinary four-banger, I was thinking first. But then I realized it conforms to algebraic notation:

2+3*4 = 14
(2+3)*4 = 20

Up to 16 places can be displayed, however at most 6 places after the decimal point:

1000*1000*1000*1000*1000 = Out of range
1000*1000*1000*1000*1000-1 = 999999999999999
(1000*1000*1000*1000*1000*1000-1000)/1000 = 999999999999999
(1000*1000*1000*1000*1000-1)/1000 = 999999999999.999

355/113 = 3.141593 355000000000/113 = 3141592920.353982

1234567890+0.123456 = 1234567890.123456 12345678901+0.123456 = 12345678901.1235 123456789012+0.123456 = 123456789012.123

9876543210+0.123456 = 9876543210.123455 98765432109+0.123456 = 98765432109.1235 987654321098+0.123456 = 987654321098.123

Extracting the square root can be done iteratively since you can edit the last computation:

(3/1+1)/2 = 2
(3/2+2)/2 = 1.75
(3/1.75+1.75)/2 = 1.732143
(3/1.732143+1.732143)/2 = 1.732051
(3/1.732051+1.732051)/2 = 1.732051

Error messages are nice:

1/0 = Can't divide by zero

But then I stumbled over the following:

23+17% = Syntax Error

Only after a while I found out how to use the percentage operation:

23%17 = 6
355%113 = 16

  • Who'd consider modulo a basic arithmetic function?
  • Have you ever noticed the use of % for this operation in a calculator? (I know it's common in many computer languages.)

Kind regards
Thomas

Edited: 10 Dec 2009, 8:54 p.m.

      
Re: OT: basic arithmetic functions
Message #2 Posted by hugh steers on 10 Dec 2009, 9:03 p.m.,
in response to message #1 by Thomas Klemm

im thinking the calculator in your phone is working in binary IEEE754 and compiled with the usual runtime mathlib.

you could check by calculating, say 1/17 and then multiplying and subtracting the significant figures. if it's binary, the numbers will go on and on and you will get garbage after 16 digits. if it's decimal, you will hit the zeros.

            
Re: OT: basic arithmetic functions
Message #3 Posted by Thomas Klemm on 15 Dec 2009, 4:35 p.m.,
in response to message #2 by hugh steers

First I was in doubt since e.g. 1/17*17-1 would just result in 0 as expected. Only after a while I came up with the following expression:

(1-(1000000-999999.999999)*1000000)*10000000000000

Using Python results in:

-76144933.700561523

While the calculator of my phone would yield:

-76144933.700562

I couldn't get any more places since the input field is limited to 50 characters.

So it seems intermediate results are calculated using binary while the result is rounded to 6 places after the decimal point.

Of course HP-calculators using BCD don't encounter problems with this expression.


[ Return to Index | Top of Index ]

Go back to the main exhibit hall