Re: MATH_MOD: Include in GLib?

On 26.07.2004, at 13:29, Jan Kratochvil wrote:

#define G_MOD(x, m) ((x) >= 0 ? (x) % (m) : (m) - 1 - ((-(x) - 1) % (m)))

I'm all for it. This is very useful for several diffent kinds of
applications and obviously not trivial to get right *and* efficient.

Regarding the special cases Owen mentioned: I would ultimately
expect that the compiler guys figure out how to optimize it;
known performance problems can still be fixed by manual
optimizations or a more sophisticated version of the macro which
utilizes compiler goodies to make it really fast.

I'd like to see a reasonable testcase though in case this gets
some corner cases wrong....


Attachment: PGP.sig
Description: This is a digitally signed message part

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