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]

Re: rint -lm function broke


>>>>> Robert Thomas writes:

 > Hello Gnu (Skip narrative goto BUG label on left)
 > 	This bug involves the rint function.  I have debugged it as far as
 > as I can and I'm not sure what is wrong without getting an assembler book
 > to debug the asm.

 > 	We are using mysql to render web data and mysql was compiled on a
 > RH Linux 6.2 box using gcc (and egcs,gcc-2.95.2, it didn't matter).  This
 > error is also reproduceable on a Sun Solaris 2.8 box using gcc and sun's
 > libm.



 > BUG:


 > 	rint under gcc rounds down if the major part is even and the
 > minor is exactly 5, rounds correctly if the major part is odd.  I really
 > don't think that this is the actual library rint problem, it seems to be a
 > gcc problem.  Here is some very reproduceable (raw) code to show this and 
 > this was rendered from the actual mysql code eliminating and
 > simplifying lines for readability:

From ISO C99:
       [#2] The rint functions differ from the nearbyint  functions
       (7.12.9.3)  only  in  that  the rint functions may raise the
       ``inexact'' floating-point exception if the  result  differs
       in value from the argument.

       [#2] The nearbyint functions  round  their  argument  to  an
       integer  value  in  floating-point format, using the current
       rounding  direction  and  without  raising  the  ``inexact''
       floating-point exception.

The current rounding mode is round to even (aka round to nearest) -
and does exactly what you describe.

Andreas
-- 
 Andreas Jaeger
  SuSE Labs aj@suse.de
   private aj@arthur.inka.de
    http://www.suse.de/~aj

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