arithmetic problem
Horst von Brand
vonbrand@inf.utfsm.cl
Tue Nov 30 23:39:00 GMT 1999
Christoph Passon <c5016839@ls3510.wdf.sap-ag.de> said:
> some of our developers came up to the LinuxLab here at SAP and stated
> that there is a strange behaviour under Linux which they do not find
> under any other Unix platform. The behaviour occurs when assigning a
> double to an integer after performing a calculation which is close to
> the arithmetic limit of significanse.
This might be (a) a FPU (design) problem, (b) a compiler problem. Did you
try other Unices on ia32? Other compilers? Windows? Rephrased and
compilable, your fragment is:
#include <stdio.h>
main()
{
int ires, idres;
double dres;
int i = 10000000;
ires = i * 0.000001 ;
dres = i * 0.000001 ;
idres = dres ;
printf("ires = %d, idres = %d\n", ires, idres);
}
> The resulting value of ires and idres differ (ires is 9 and idres is
> 10).
Here (sparc32, RedHat 6.0 + updates, gcc-2.95.2) I get 10 and 10, both
without optimization and with -O2 -fomit-frame-pointer.
PS: HTML is usually not wellcome on mailing lists.
--
Dr. Horst H. von Brand mailto:vonbrand@inf.utfsm.cl
Departamento de Informatica Fono: +56 32 654431
Universidad Tecnica Federico Santa Maria +56 32 654239
Casilla 110-V, Valparaiso, Chile Fax: +56 32 797513
More information about the Gcc-bugs
mailing list