home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / std / c / 3197 < prev    next >
Encoding:
Internet Message Format  |  1992-12-13  |  1.4 KB

  1. Path: sparky!uunet!sdrc!thor!scjones
  2. From: scjones@thor.sdrc.com (Larry Jones)
  3. Newsgroups: comp.std.c
  4. Subject: Re: mathematical modulo operation
  5. Message-ID: <2389@sdrc.COM>
  6. Date: 13 Dec 92 17:06:17 GMT
  7. References: <Byx9D9.5v7@jrd.dec.com> <1254@zogwarg.etl.army.mil> <1992Dec12.231115.26787@sq.sq.com>
  8. Sender: news@sdrc.COM
  9. Lines: 18
  10.  
  11. In article <1992Dec12.231115.26787@sq.sq.com>, msb@sq.sq.com (Mark Brader) writes:
  12. > It's still a puzzle to me why, having provided the above definition,
  13. > they then proceeded to specify the library functions div() and ldiv()
  14. > as they did, but not provide functions that would provide the mathematical
  15. > modulo function, which I think is more useful.  But this is incidental.
  16.  
  17. The idea behind div()/ldiv() is that many machines have a single
  18. instruction that provides both the quotient and remainder in a single
  19. operation, either in addition to, or instead of, instructions that
  20. produce only one or the other.  Many algorithms require both, but it
  21. can be quite difficult for an optimizer to recognize that that is what
  22. is happening when the division and remainder are completely separate
  23. operations, so the library functions were added to provide an easy way
  24. to provide this optimization.
  25. ----
  26. Larry Jones, SDRC, 2000 Eastman Dr., Milford, OH  45150-2789  513-576-2070
  27. larry.jones@sdrc.com  or  ...uunet!sdrc!larry.jones
  28. I won't eat any cereal that doesn't turn the milk purple. -- Calvin
  29.