Article View: comp.std.c
Article #1189Re: Scientists as Programmers (was Re: Small Language Wanted)
From: Paul Eggert
Date: Fri, 11 Sep 1992 02:04
Date: Fri, 11 Sep 1992 02:04
17 lines
1209 bytes
1209 bytes
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!
Technical Details
Message-ID:
<bj'-3cS=@twinsun.com>Path:
arc1-ca.pugleaf.net!sparky!uunet!elroy.jpl.nasa.gov!ucla-cs!twinsun!eggertReferences:
<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>Show Full Headers
Complete Article Headers
Newsgroups: comp.std.c Path: arc1-ca.pugleaf.net!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