Oracle FAQ Your Portal to the Oracle Knowledge Grid

Home -> Community -> Usenet -> comp.databases.theory -> Re: Possreps and numeric types

Re: Possreps and numeric types

From: Matthias Klaey <>
Date: Thu, 29 Mar 2007 01:24:10 +0200
Message-ID: <>

"V.J. Kumar" <> wrote:

>Matthias Klaey <> wrote in
>> "V.J. Kumar" <> wrote:
>>>"David Cressey" <> wrote in
>>>> "V.J. Kumar" <> wrote in message
>>>> news:Xns98FFEB79C9D6Bvdghher_at_217.22.228.20...
>>>>> Matthias Klaey <> wrote in
>>>>> > I used to teach that if you calculate "2 + 2" on a computer, the
>>>>> > result would be somewhere between 3 and 5,
>>>>> You are kidding, right ? If not, you might want to fix your
>>>>> computer for the sake of your poor students at least !

>> The result you will get is that
>> 21200 * 1.025 *is not equal to* 21730
>> because 21200 * 1.025 is repersented as 40D5387FFFFFFFFF
>> and 21730 is represented as 40D5388000000000
>It is very sweet of you to provide a trivial and very well known to any
>programmer demonstration that IEEE 754/854 floating point implementation
> does not (and cannot) represent *all* real numbers and that may create
>problems, but what has it got to do with your absurd statement that
>"2+2" is somewhere between 3 and 4 ?

If this were *very well known to any programmer*, this would exclude about 99% of all people who write code today as being *programmers*. The most trivial questions about floating point arithmetic are asked *several times daily* in the newsgroups, most in the form of an outraged cry "There is a BUG in System XY! It cannot add numbers!"

>> The "Swiss" part is that I am using dramatic oversimplification
>Your statement about "2+2 != 4" is not a "dramatic oversimplification"
>but simply false even with IEEE 754 representation. Some students of
>yours may actually believe that nonsense !

While this seems to be true for Intel processors, there are many other processor types and programming languages out there. When, exactly, was the last time you checked the accuracy of your specific floating point arithmetic hardware/software, according to, say, Kahan's paranoia test?

(and please follow the links in this article...:-)

And, from a didacticatl point of view of course I follow this statement with the approppriate explanations. To me it is more of a strong warning sign that you should keep in mind when dealing with floating point arithmetic. And by the way, the statement itself is not false: The "acidentally" exact answer of 4 clearly fulfills the statement of "being somewhere between 3 and 5".

I hope I could clarify this issue.
Matthias Kläy

Received on Wed Mar 28 2007 - 18:24:10 CDT

Original text of this message