Man page issue: fmod

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

 



The fmod man page recommends this code to get the least positive residue:

    z = fmod(x, y);
    if (z < 0)
         z += y;

That last line should be "z += fabs (y);"  Otherwise, for x=-0.25 and
y=-1 you get z=-1.25 which isn't what anyone is looking for.

The man page could perhaps also state that the sign of y has no effect
on the output, other than possibly when the result is a NaN.

M.




[Index of Archives]     [Kernel Documentation]     [Netdev]     [Linux Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux