arithmetic problem
Dima Volodin
dvv@dvv.ru
Tue Nov 30 23:39:00 GMT 1999
Is it something in the air or the quality of programming public's
education goes down the drain fast?
On Tue, 30 Nov 1999 16:53:42 +0100, Christoph Passon wrote:
> int ires, idres;
> double dres;
>
> i = 10000000;
>
> ires = i * 0.000001 ;
> dres = i * 0.000001 ;
> idres = dres ;
>
>The resulting value of ires and idres differ (ires is 9 and idres is
>10).
>This divergence occurs every 10^6 value starting with i=10^7. (Doing
>this just with floats instead of double does some more "abnormal"
>behaviour, but since the other Unix derivates also have divergenses
>doing that assignment (although at much less points in the integer
>space), we do not bother).
>We do not regard this as a bug, since the standard is not very precise
>in this point, but it would really be nice if Linux would behave like
>the other platforms (tested AIX, Solaris, HPUX) by assigning the same
>value.
The standard is very precise in this point stating that you cannot
expect the same value for ires and dres.
>Chris
Dima
More information about the Gcc-bugs
mailing list