Article View: comp.arch
Article #10855Re: how to advocate new software/hardware features (Re: Hardware Support for Numeric Algorithms)
From: Thomas M. Breuel
Date: Sun, 15 Nov 1992 21:30
Date: Sun, 15 Nov 1992 21:30
35 lines
1785 bytes
1785 bytes
In article <TMB.92Nov14145619@pollux.idiap.ch> tmb@pollux.idiap.ch (Thomas M. Breuel) writes:
Even the C language has provisions for just the case that you are
concerned with in the case of 16bit integers, 32bit longs:
int a = ...;
int b = ...;
int c = ...;
long product = a*b;
int result = product/c;
In fact, on some machines, int is 32bit and long is 64bit,
so this code will do what you want.
Furthermore, C is being extended to allow access to 64bit types,
so that you can write:
int a = ...;
int b = ...;
long long product = a*b;
int result = product/c;
Oops, that should, of course have been:
long product = (long)a*(long)b;
and
long long product = (long long)a*(long long)b;
Now, _my_ pet peeve with C is that this bug would have gone
undetected... (a compiler should warn about the lack of a conversion,
and a runtime system should catch any overflow).
Thomas.
Technical Details
Message-ID:
<TMB.92Nov15213027@arolla.idiap.ch>Path:
arc1-ca.pugleaf.net!sparky!uunet!snorkelwacker.mit.edu!ai-lab!life.ai.mit.edu!tmbReferences:
<1992Nov10.153705.27804@yrloc.ipsa.reuter.COM> <1992Nov12.131856.12605@linus.mitre.org> <TMB.92Nov13144057@arolla.idiap.ch> <1992Nov13.155126.3660@linus.mitre.org> <TMB.92Nov14145619@pollux.idiap.ch>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!snorkelwacker.mit.edu!ai-lab!life.ai.mit.edu!tmb From: tmb@arolla.idiap.ch (Thomas M. Breuel) Newsgroups: comp.arch,comp.lang.misc Subject: Re: how to advocate new software/hardware features (Re: Hardware Support for Numeric Algorithms) Date: 15 Nov 92 21:30:27 Organization: IDIAP (Institut Dalle Molle d'Intelligence Artificielle Perceptive) Lines: 35 Message-ID: <TMB.92Nov15213027@arolla.idiap.ch> References: <1992Nov10.153705.27804@yrloc.ipsa.reuter.COM> <1992Nov12.131856.12605@linus.mitre.org> <TMB.92Nov13144057@arolla.idiap.ch> <1992Nov13.155126.3660@linus.mitre.org> <TMB.92Nov14145619@pollux.idiap.ch> Reply-To: tmb@idiap.ch NNTP-Posting-Host: arolla.idiap.ch In-reply-to: tmb@pollux.idiap.ch's message of 14 Nov 92 14:56:19