Calculator?

arri

Registered
where on earth does the apple-calculator get these values:

28 + 29.50 + 57.5 + 39.9 + 20.60 + 15 + 6.8 + 6.8 + 2 + 2 + 1.2 + 6.8 + 6.8 + 70 + 39.9 + 50 + 80 + 35 + 29.75 + 92.95 + 9.28 + 4 + 73.65 + 9.95 + 2.05 + 20 + 2.4 + 6.8
= 691.1299999999999


i mean, just adding these values should just return a number with two digits behind the point...


strange
 
well im geting 707.43 and i checked it 4 times! why is ther an extra "+" before the "=" sign just a typo? there have been other threads about calculator doing weird things i *think* but the sum u put up seems fine on my comp (G3 imac 10.2.8) - see signature) calculator v 3.0
 
been there, done that

quick search will fill ya'll in. Then come on down to the pool, the water's fine and there are new shrimps on the grill!
 
When I run your numbers through Calculator 3.1, or Top Calculette Pro I get the same answer: 748.63. It is only on calculator's "paper tape" where I see 748.6299999999999 which, when rounded off to two decimal places, becomes 748.63. The "paper tape" shows 748.6299999999999 because the internal calculations are performed using floating point values and Calculator is displaying the results it gets before rounding. If you will set View > Precision to two decimal places you will see the result you are looking for.
 
I'm begging to be proved wrong here, but AFAIK the repeating digits are caused because computers use binary (base 2) math instead of decimal (base 10) math, not because of the floating point unit. A floating point unit allows a processor to perform certain mathematical operations in the hardware rather than software. Most all modern computers have built-in FPUs (Floating Point Units), with the exceptions being some early 68k Macs.
 
ElDiabloConCaca said:
I'm begging to be proved wrong here, but AFAIK the repeating digits are caused because computers use binary (base 2) math instead of decimal (base 10) math
Wow, your comment caused a flashback to advance computer science classes 35 years ago. If memory serves, this covers at least a weeks worth of lectures and explanations. Your supposition is at least partially true, all number representation and manipulation in computers is binary. When dealing with decimal values there are two ways it can be handled:
  1. Convert each digit in the decimal number to a binary equivalent then, in software performing essentially the same steps a human would take to perform the operation. This provides what I term accounting accuracy but it is relatively slow because each digit has to be converted and processed separately. This is the technique used for fixed point in COBOL which at least partially explains its popularity in accounting applications.
  2. Convert the entire number to a single binary equivalent value then perform the mathematical operations on the binary numbers in a single operation. This is obviously far faster but it has the disadvantage that in the conversion there are inevitable approximations and rounding in converting to and from binary when fractional values are involved. Usually these rounding errors are insignificant but accuracy can be increased even further by increasing the number of bits used to represent the number. Ie. single precision vs. double precision.
Calculator is obviously, and not surprisingly, using the second method to do its thing. Thus on the "paper tape" you are seeing the result of the conversion process which yielded a very close approximation of the correct value. If you select two decimals in the display, the approximation is rounded to the correct value. The downside is the rounding may result in a slight rounding error. When it is two decimal points, I would not expect that to exceed +/- .01 or .02 and then only with very large numbers.

Previously when I referred to floating point I was carelessly referring to this second method of representation because the binary value is actually a floating point number. Whether the mathematical operation is actually performed in the FPU or not. Of course on G3s there is no FPU nor are there FPUs on many IBM versions of the PowerPC processor. IBM feels they can optimize the entire processor better without the FPU, thus negating any speed advantage from a dedicated co-processor.
 
Ah, that explanation was perfect. Thanks for clarifying the hardware/software FPU as well -- I thought that all modern machines did have a hardware FPU -- I remember back in the early 90s working on 68k Macintoshes as well as Power Macintoshes when certain programs (for example, early versions of Bryce) refused to run on certain machines, complaining that an FPU wasn't present. I suppose processors are now powerful enough to do all FPU calculations in software, as opposed to having a built-in hardware FPU.
 
well, thanks for all these explanations.
makes it all very clear.

ofcourse was not too much bothered by a float..
just wondered how the machine would end up with such a funny number,
which is caused by the FPU (calculating binary) as i understand.

and yess, i was looking at the paper-tape, as i was trying to keep track of all calculations
(trying to finish TAX-paperwork...), when i saw these odd numbers.
especially when you imagine i should round the final numbers to integers (nl) ..

i guess men and machines work different then

regards,
arri
 
Back
Top