home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.std.c
- Path: sparky!uunet!elroy.jpl.nasa.gov!ucla-cs!twinsun!eggert
- From: eggert@twinsun.com (Paul Eggert)
- Subject: Re: Scientists as Programmers (was Re: Small Language Wanted)
- Message-ID: <bj'-3cS=@twinsun.com>
- Sender: usenet@twinsun.com
- Nntp-Posting-Host: farside
- Organization: Twin Sun, Inc
- 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>
- Date: Fri, 11 Sep 1992 02:04:06 GMT
- Lines: 17
-
- a_rubin@dsg4.dse.beckman.com (Arthur Rubin) writes:
-
- >> int a, b;
- >> long c;
-
- >> c = a * b;
-
- >(peter commented further that this works on a PDP-11).
- >Aside from there being no guarantee that "long" is longer than "int", I
- >don't think it is LEGAL for ANSI C to do this
-
- No, a conforming C implementation can use an n*n -> 2n multiplication
- primitive in this case. If (int) (a*b) would not overflow, then you
- get the same answer either way, so the `as-if' rule applies; and if
- (int) (a*b) would overflow, then the result is undefined, so the
- implementation can do what it pleases, including delivering the
- mathematically correct answer!
-