Article View: alt.msdos.programmer
Article #1202Re: typecasting preferences
From: Rich Alloway
Date: Wed, 17 Apr 1996 01:06
Date: Wed, 17 Apr 1996 01:06
18 lines
1003 bytes
1003 bytes
On Tue, 16 Apr 1996, Jes R. Klinke wrote:
> a := 10000; b := 10000;
> c := longint(a * b); { Bad, overflow occurs before typecast }
> c := longint(a) * b; { Good, typecast then multiply }
>
> I don't know how you distinguish between these cases in C++ (I have
> never done any serious programming in C).
> Jes R Klinke
How about:
c = (long)(a * b);
c = (long)a * b;
This form seems to work for me... :)
Rich
Technical Details
Message-ID:
<Pine.LNX.3.91.960416210500.11159A-100000@mailer.pennet.com>Path:
arc1-ca.pugleaf.net!mailer.pennet.com!rallowayReferences:
<4l020g$i9j@srvr1.engin.umich.edu> <3173fb39.0@193.89.47.9>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!mailer.pennet.com!ralloway From: Rich Alloway <ralloway@pennet.com> Newsgroups: alt.msdos.programmer,comp.lang.c,comp.lang.pascal.misc Subject: Re: typecasting preferences Date: Tue, 16 Apr 1996 21:06:15 -0400 Organization: PENNET, Internet access Message-ID: <Pine.LNX.3.91.960416210500.11159A-100000@mailer.pennet.com> References: <4l020g$i9j@srvr1.engin.umich.edu> <3173fb39.0@193.89.47.9> NNTP-Posting-Host: mailer.pennet.com Mime-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII In-Reply-To: <3173fb39.0@193.89.47.9>