Re: Possreps and numeric types
Date: 28 Mar 2007 13:26:09 +0200
Message-ID: <Xns99014C3B43749vdghher_at_217.22.228.20>
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 !
>>>
>>> I think you missed the irony in the original teaching. If you are
>>> working with integers,
>>> there is only one answer that is somewhere between 3 and 5.
>>
>>I may be missing the irony, but how can adding integer 2 and 2 can
>>produce anything but 4 ? "Somewhere" implies vagueness or ambiguity,
>>at least in the English I am accustomed to. Is it some sort of new
>>post- modern kind of math, or English, I am unfamiliar with ? It
>>seems that the Swiss secondary education system is in even worse shape
>>than the American !
>>
>>> Everything works. If you are working with floating point numbers,
>>> and approximations, you can get some nasty surprises.
>>
>>Not when adding floating 2.0 and 2.0, it is still 4.0 surprisingly
>>enough for some !
>
> [...]
>
> Here is a very simple "real world" example such as an interest
> calculation on a capital (capital 21200$, interest 2.5%, calculate
> capital + interest):
>
> 21200 * 1.025 = 21730
>
> As you can verify easily with hand calculation, this is exact.
>
> Now evaluate this same calculation with any computer language that
> implements the IEEE 854 standard (such as C, C++, Java, the .NET
> languages, Visual Basic, Delphi and numerous others, also MS SQL
> Server, Oracle; basically *all* languages that rely on the Intel
> Floating Point architecture).
>
> 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 ?
> 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 !
>
> Greetings
> Matthias Kläy
Received on Wed Mar 28 2007 - 13:26:09 CEST