[fpc-pascal] Re: Why this evaluates on "if" wrong ?
Jonas Maebe
jonas.maebe at elis.ugent.be
Mon Oct 29 14:51:17 CET 2007
On 29 Oct 2007, at 15:30, L wrote:
>> It's just one more funny thing one must realize,
>> when comparing real numbers with some exact
>> real constants. After this, I will try to never
>> compare doubles directly, but using tricks like
>> above. Because, in this digital world
>> 1 + 0.4 - 0.4 <> 1.
>
> My opinion:
> This is ludicrous.
>
> The end user is using a high level language and should not care
> whether the
> computer is digital or analog.
It's not about digital vs analog, it's about limited precision. And
you simply cannot ignore that, unless you only use extremely high
level primitives. For example, when adding a bunch of floating point
numbers, you should sort them from small to large because otherwise
you lose a lot more precision. So unless you use an "AddFloat
(realarray, count): float" function, you also have to care.
> For example, my calculator subtracts 0.4 just fine, and it is digital!
It has been explained earlier in this thread why that is so.
> I don't care about decimal points or any other excuses. THe fact is
> people
> expect languages on computers to work like their calculator does or
> like
> how grade school math worked.. simple, sensible.
Then they should not use floating point in programming languages, but
Mathlab, Maple, or special purpose libraries/types.
Jonas
More information about the fpc-pascal
mailing list