Re: Float math and calculators vs. computers

Generally, calculators use BCD, so they work in base 10.

BCD is a pretty wasteful data representation, so computers usually work in binary.

Calculators also go to great lengths to hide those kinds of displays by using extra "hidden" digits and stuff. Computers are supposed to be programmed by people who know what they are doing.

Your calculator is also rounding digits for display purposes. It rounded 3.9999999 to 4.0000000 and then realized that it was silly to display all those zeros, so it showed 4. The Arduino did the same calculation, and got the same answer. You asked it to display the output the way you wanted to see it, not the way it wanted to show it to you.

Calculators do "school" maths eg 3/2 = 1+1/2. However computer to integer and real math (look up number theory). The too are very different!.

For example 1/0 or even 1.0/0.0 does not equal infinity, in integer or real math, it is just undefined ie (anything/0 is undefined or just not allowed. Forget what your teacher, said look it up!. Google "number theory".

Mark

Holmes4:
What?
What does 1/0 have to do with anything? My HP71B could return any number of values depending on a flag setting.

I think my HP41 handles it correctly, too.

When I 'GO', I'm taking my HP 32Sii with me with spare batteries. :wink:

Calculators are carefully designed to do their calculations with more digits of precision than the display will actually display, and then they round properly.

Computer languages in general, and the Arduino libraries in particular, ... not so much. But it calculates an ALMOST correct answer much faster than most calculators!

Delta_G ...

Try the following on your calculator:

1.99999999999 ^ 1.99999999999

My advanced calculator comes up with an answer of "4", which is not 'exactly' correct. How about yours?

Calculators ARE 'computers' ... with very specific capabilities and programming. Whoever does the programming uses the resources available to determine what is shown on the display.

Blessings in abundance, all the best, & ENJOY!
Art in Carlisle, PA USA

webtest:
Delta_G ...

Try the following on your calculator:

1.99999999999 ^ 1.99999999999

My advanced calculator comes up with an answer of "4", which is not 'exactly' correct. How about yours?

Mine (HP 42S) gives -

3.99999999993

Edit: My VERY cheap $3 Casio gives 3.9999996 (I could only enter 7 digits after the decimal place on that one).

Win XP integrated one comes up with 3,9999999999322741127782755370983

EDIT:
Both my Casio FX-991-ES PLUS and Citizen SR-270X return 4 if I put in 11 or more 9s in both base and exponent. 10 9s and I get <4.

1.99999999999 ^ 1.99999999999

My calculator won't perform an XOR on floating point values. Did you mean 1.999999999991.99999999999?

AWOL:

1.99999999999 ^ 1.99999999999

My calculator won't perform an XOR on floating point values. Did you mean 1.999999999991.99999999999?

Nerd

Lefty

AWOL:
My calculator won't perform an XOR on floating point values.

You gotta get one of those new, really advanced calculators to do that. :slight_smile:

Delta_G:
what does my calculator have that my Arduino or even my computer doesn't?

The answer is that it has different technology for a different purpose. Its job is to tell you the bleeding obvious, 8/4=2, and look like it knows what it's doing. This it does, but at the sacrifice of speed. Computers are all about speed and efficiency and I guess it is more efficient to do the deed , and, only if needed, apply the cosmetics after the event.

Back in the days of the s100 bus, I recall there was a dedicated scientific calculator chip that enabled a computer to deliver what you want to see. I imagine its validity today is the same as it was then.

My calculator won't perform an XOR on floating point values.

Have you tried turning it off and on again?

Have you tried turning it off and on again?

Or rebooting?
Or reinstalling the operating system?
Or contacting your system administrator?
Or any of the other dumb shit that Microsoft recommends before they admit that it is their code that sucks.