From: | bobduff@world.std.com (Robert A Duff) |
Newsgroups: | comp.compilers,comp.dsp |
Date: | 14 Mar 1996 17:20:56 -0500 |
Organization: | The World Public Access UNIX, Brookline, MA |
References: | 96-03-006 96-03-044 96-03-078 |
Keywords: | architecture |
Robert Jan Ridder <rjridder@knoware.nl> wrote:
>This is not necessarily the case if you have an optimizing
>compiler. If you want to perform an int by int multiplication to a
>long result you may write:
>
> la = (long)ia * ib;
>
>If you don't write the (long) cast the compiler is forced to do an int
>evaluation of the right part, so you will certainly lose your high
>part. In a straightforward approach the compiler will create internal
>casts to long on the integer operands, calculate the result in long
>precision and assign it. An optimizing compiler however will recognize
>the special case of long = int * int, forget about the casts and
>produce the result just like you want it to. I will not go into the
>issue of standardisation here, but you can see that it not always
>creates an inevitable burden in the end result.
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.
- Bob
--
Return to the
comp.compilers page.
Search the
comp.compilers archives again.