Re: Possreps and numeric types

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


"V.J. Kumar" <vjkmail_at_gmail.com> wrote:

>Matthias Klaey <mpky_at_hotmail.com> wrote in
>news:6l7j03di6tdmf1k68s7oa2d6fto0lv9ko3_at_4ax.com:
>
>> "V.J. Kumar" <vjkmail_at_gmail.com> wrote:
>>
>>>"David Cressey" <cressey73_at_verizon.net> wrote in
>>>news:KD2Oh.1604$Rp2.1491_at_trndny04:
>>>
>>>>
>>>> "V.J. Kumar" <vjkmail_at_gmail.com> wrote in message
>>>> news:Xns98FFEB79C9D6Bvdghher_at_217.22.228.20...
>>>>> Matthias Klaey <mpky_at_hotmail.com> wrote in
>>>>> news:gqsg031cmfnr5p5fbiokksmaf8psios4hh_at_4ax.com:
>>>>>
>>>>> > 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?

 http://en.wikipedia.org/wiki/William_Kahan

(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.
Greetings
Matthias Kläy

-- 
www.kcc.ch
Received on Thu Mar 29 2007 - 01:24:10 CEST

Original text of this message