[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#134097: not a bug? (libc6: drem() unexpectedly changes signs (demo code))



Hi,

This isn't a bug, unless I am missing something  The function is
behaving as documented[1].  I don't have a copy of the standard
(IEEE-754) but other sources ([2],[3]) indicate that the glibc
documentation is correct.

>From drem(3) :

   The  drem()  function  computes  the remainder of dividing x by y.  The
   return value is x - n * y, where n is the quotient of x / y, rounded to the
   nearest integer.  If the quotient is 1/2, it is rounded to the even number.


In the example provide in the report y is always 0.5.

For x = 0 , x < 0.25 the quotient x/y is rounded down (n = 0). So the function
should return x - 0y = x

For x > 0.25 , x < 0.5 the quotient x/y is rouded up (n = 1). So the function
should return x - y

For x > 0.5 , x < 0.75 the quotient is again rounded to 1, so we should get x - y

For x > 0.75 , x < 1 the quotient is rounded up to 2, so we should get x - 2y


-David

[1] : http://www.gnu.org/manual/glibc-2.0.6/html_node/libc_267.html or drem(3).
[2] : http://www.neosoft.com/neosoft/man/ieee.3.html
[3] : http://www.informatik.uni-frankfurt.de/doc/man/hpux/drem.3m.html



Reply to: