Re: MATH_MOD: Include in GLib?


Daniel Brockman <drlion deepwood net> writes:

> > > Also note that your suggest macro won't work if x < m.
> What do you mean?  Assuming that x % m == -(-x % m) whenever x < 0
> (which is allegedly machine-dependent), it works in all these cases,
> as far as I can tell, and x < m in all of them:

The behaviour for negative operands is by definition undefined. This
it doesn't make sense to make any assumptions about it. Any macro that
passes a negative operand to the C modulo operator is broken. No
matter how well it may seem to work.


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