🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #3012

Re: mathematical modulo operation

#3012
From: Larry Jones
Date: Sun, 13 Dec 1992 17:06
18 lines
1453 bytes
In article <1992Dec12.231115.26787@sq.sq.com>, msb@sq.sq.com (Mark Brader) writes:
> It's still a puzzle to me why, having provided the above definition,
> they then proceeded to specify the library functions div() and ldiv()
> as they did, but not provide functions that would provide the mathematical
> modulo function, which I think is more useful.  But this is incidental.

The idea behind div()/ldiv() is that many machines have a single
instruction that provides both the quotient and remainder in a single
operation, either in addition to, or instead of, instructions that
produce only one or the other.  Many algorithms require both, but it
can be quite difficult for an optimizer to recognize that that is what
is happening when the division and remainder are completely separate
operations, so the library functions were added to provide an easy way
to provide this optimization.
----
Larry Jones, SDRC, 2000 Eastman Dr., Milford, OH  45150-2789  513-576-2070
larry.jones@sdrc.com  or  ...uunet!sdrc!larry.jones
I won't eat any cereal that doesn't turn the milk purple. -- Calvin
Technical Details
Message-ID: <2389@sdrc.COM>
Path: arc1-ca.pugleaf.net!sparky!uunet!sdrc!thor!scjones
References: <Byx9D9.5v7@jrd.dec.com> <1254@zogwarg.etl.army.mil> <1992Dec12.231115.26787@sq.sq.com>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!sdrc!thor!scjones
From: scjones@thor.sdrc.com (Larry Jones)
Newsgroups: comp.std.c
Subject: Re: mathematical modulo operation
Message-ID: <2389@sdrc.COM>
Date: 13 Dec 92 17:06:17 GMT
References: <Byx9D9.5v7@jrd.dec.com> <1254@zogwarg.etl.army.mil> <1992Dec12.231115.26787@sq.sq.com>
Sender: news@sdrc.COM
Lines: 18