home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / std / c / 2604 < prev    next >
Encoding:
Text File  |  1992-09-10  |  1.2 KB  |  30 lines

  1. Newsgroups: comp.std.c
  2. Path: sparky!uunet!elroy.jpl.nasa.gov!ucla-cs!twinsun!eggert
  3. From: eggert@twinsun.com (Paul Eggert)
  4. Subject: Re: Scientists as Programmers (was Re: Small Language Wanted)
  5. Message-ID: <bj'-3cS=@twinsun.com>
  6. Sender: usenet@twinsun.com
  7. Nntp-Posting-Host: farside
  8. Organization: Twin Sun, Inc
  9. References: <92Sep1.205116edt.669@neuron.ai.toronto.edu>   <1992Sep4.162938.29237@dscomsf.desy.de> <Bu2r42.5xr@mentor.cc.purdue.edu> <id.I12T.GP4@ferranti.com> <a_rubin.716152347@dn66>
  10. Date: Fri, 11 Sep 1992 02:04:06 GMT
  11. Lines: 17
  12.  
  13. a_rubin@dsg4.dse.beckman.com (Arthur Rubin) writes:
  14.  
  15. >>    int a, b;
  16. >>    long c;
  17.  
  18. >>    c = a * b;
  19.  
  20. >(peter commented further that this works on a PDP-11).
  21. >Aside from there being no guarantee that "long" is longer than "int", I
  22. >don't think it is LEGAL for ANSI C to do this
  23.  
  24. No, a conforming C implementation can use an n*n -> 2n multiplication
  25. primitive in this case.  If (int) (a*b) would not overflow, then you
  26. get the same answer either way, so the `as-if' rule applies; and if
  27. (int) (a*b) would overflow, then the result is undefined, so the
  28. implementation can do what it pleases, including delivering the
  29. mathematically correct answer!
  30.