This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

arithmetic problem


Hi,

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.
We are conscious that just assigning a real to an int does not gurarntee
a correct value. But the divergence of Linux in this particular case is
really strange. The basic operations that result in the "error" is of
the form

      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.

Bye,

Chris
 

-- 
                                                               .--.
                                                              |o_o |
Christoph Passon__________________________________________    |:_/ |
realTech GmbH                           passon@realtech.de   //   \ \ 
z.Zt.SAP AG                     christoph.passon@sap-ag.de  (|     | )
Linux LAB                                                  /'\_   _/`\
+49 (6227) 7-62052                                         \___)=(___/
 
Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]