PDA

View Full Version : A conspiracy? YOU be the judge!


Palsgraf
11-19-2008, 03:30 AM
So I was bored at work and using the calculator function on a touchscreen computer terminal for some non-work-related math. The numbers I was entering - mortgage payments - were much larger than what we actually use the calculators for (ex. divide a $432.56 check seven ways, etc.)

But as I went along, the numbers just stopped making sense.

Then I did some simple calculations with large numbers to test it.

500 x 500 = something with a 25 and a bunch of zeros, right?

Maybe 250,000?

But according to our computer, 500 x 500 = -179,496.72

That's right: somewhere it picked up a decimal, and became negative.

(I often pick-up a decimal and become negative at work too!)

600 x 600 = -69,496.72

So the "9,496.72" part seems to be a popular response ...

Is this just some computer glitch?

(Maybe one of you computer-savvy folks will look at this and quickly diagnose the problem as, "Ah, you've got the recalled Intel 9,496.72 chip from 1993! Sucks to be you!").

Or have I stumbled on to something else ...

Something intentional ...

Something far more sinister ...

Could this have something to do with the tax changing on a check that I haven't altered? (ex. I'll print the check to take to the customer, but when I return to charge the balance to the customer's credit card, the tax will jump up one cent!)

Does that benefits guy I'm always leaving voicemails for at corporate have a giant jar of pennies on his desk?

Is the reason he can't answer his phone because he's counting pennies?

Or because he's emptying the jar into the trunk of his car each time it fills up (perhaps up three times a day - five on the weekends)?

Will I - after posting proof of the computing discrepancy - suddenly disappear without a trace??!!!

:wave:

Aethian
11-19-2008, 03:53 AM
Sounds like some previous calculation never got fully cleared out. CE = clear entry C = Clear

Clear entry only takes off whats on the calculators screen... clear makes everything be cleared out and takes it down to zero.

Pedersen
11-19-2008, 05:29 AM
Ah, you've just entered into the world of binary math, which is a true joy, I can tell you.

If you want, I'll give you full primers and links. But, be forewarned, it ain't fun.

Here's what it comes down to: Computers are able to display certain numbers easily. A 16 bit computer can easily handle numbers from 0 to 65535, for example.

The problems started with negative numbers. The computer doesn't inherently understand the idea of -1. So, some tricks were used, and some properties of binary math discovered, which resulted in ways to effectively make the computer understand negative numbers.

Depending on the computer, this is done using either one's complement or two's complement. There's a wikipedia article (http://en.wikipedia.org/wiki/One's_complement) that discusses this in some detail.

Then came another problem: Computers only understand whole numbers natively. They don't understand fractional numbers. So, something as simple as 2.5 couldn't be understood. More math, more tricks, and different methods arose to allow the computer understand these numbers.

These methods are IEEE 754 (http://en.wikipedia.org/wiki/IEEE_754) and Binary Coded Decimal (http://en.wikipedia.org/wiki/Binary_coded_decimal). Each of them has their own strengths and weaknesses.

For instance, the IEEE 754 can't accurately display 2.1 in memory. It will show up that way on your screen, since the computer will round it, but in memory it's something like 2.0999999999999999999. And the BCD versions are slow to process.

All of which comes back to your original question: What's happening is that the chip is trying to do the math you've asked it to. But when it does, it runs out of bits to use. So, it moves the type of number to another type (basically), and in so doing, screws up entirely.

The programmer who wrote the calculator needs a beating, too, since the chip will tell the program that something is wrong, but that programmer didn't check to see if the chip was reporting problems. All in all, very annoying.

So, no, no specific buggy chip, and no specific issue. Just bad programming made visible.

Oh, and the tax thing? Rounding Methods (http://www.diycalculator.com/sp-round.shtml). You wouldn't believe how many ways there are to round. And how many headaches they can cause developers. And, since the computer can't accurately display the decimals in memory (most likely), you're getting to see their adverse affects. Lucky you :)

smileyeagle1021
11-19-2008, 11:17 AM
Pedersen just did an excellent explanation... I knew that there was something that caused computers to eventually go negative for no apparent reason when you had really large numbers, but that was the extent of my knowledge. Thank you Pedersen for explaining that.

draggar
11-19-2008, 12:57 PM
Ah, you've just entered into the world of binary math, which is a true joy, I can tell you.

(snip)

Nerd alert! :roll::roll:

Excellent explanation, though (and I did understand it all so I'm also setting off the nerd alert).:angel: