Mail Archives: djgpp/1996/12/02/01:41:41
Francois Charton <deef AT pobox DOT oleane DOT com> wrote in article
<32A18E63 DOT 3F09 AT pobox DOT oleane DOT com>...
>
> This is quite interesting : the "more precise" 80bit number, or the cast
> to double gives the wrong answer (mathematically I mean), whilst the
> "rough" float truncate yields the right one... (And the truncated number
> is bigger than the "less truncated" one: this is not what could be
> expected from a truncature operation on a positive number).
>
>
> Francois
>
>
His example says noting of how imprecise the two results were. The "more
precise" 80bit result may have been 113 - 1e-15 rounding correctly to 112
and the "less precise" number being 113 + 1e-13 rounding correctly to 113.
Which is why it's always a good idea to add .5 before converting it to int.
-Erik-
- Raw text -