[asterisk-users] Problem with REMAINDER? 957%60 be 15 remainder 57 not 15 remainder -3 ?

James Cloos cloos at jhcloos.com
Fri Oct 21 16:44:06 CDT 2016

I saw this on the bug list first and sent a reply, but for the archives
I'll copy it here, too.

REMAINDER() calls libm's remainder(3) or remainderl(3), infix % calls
fmod(3) or fmodl(3).

remainder(3) is defined to round the quotient to the nearest int (always
using round-to-even, notsithstanding the rounding mode), fmod(3) is
defined to trunc(3)ate the quotient.

So the result of x%y will always be in the range [0,x] and the results
of remainder(x,y) will be in the range (-y/2,y/2].

James Cloos <cloos at jhcloos.com>         OpenPGP: 0x997A9F17ED7DAEA6

More information about the asterisk-users mailing list