From: | jfc@mit.edu (John Carr) |
Newsgroups: | comp.compilers,comp.dsp |
Date: | 22 Mar 1996 00:05:41 -0500 |
Organization: | Massachusetts Institute Of Technology |
References: | 96-03-006 96-03-044 96-03-078 96-03-098 |
Keywords: | architecture |
Robert A Duff <bobduff@world.std.com> wrote:
>This is a language problem, IMHO. Languages like C and Ada and Pascal
>seem to think that integer data types have something to do with the
>underlying hardware. That's wrong. The size in bits of the result
>should be determined by the size of the operands, and not their
>"type". No casts should be needed.
Unless you move away from a static typed language, the C model has a
great advantage. If the result of an operation is defined to have
infinite precision a long expression gains bits for every operator and
the code to implement it is big and slow.
To get the exact result for
(x + y) * (a + b) / d
where all variables are 32 bits requires 66 bit arithmetic. Addition
adds 1 bit and multiplication doubles the number of bits. The quotient
has the same number of bits as the dividend.
--
John Carr (jfc@mit.edu)
--
Return to the
comp.compilers page.
Search the
comp.compilers archives again.