
On Saturday 17 September 2005 16:33, Synthetic Cartoonz wrote:
On Saturday 17 September 2005 09:00, Anders Johansson wrote:
On Friday 16 September 2005 20:19, Jerry Feldman wrote:
For instance the following code fragment is standards compliant but non-portable: long n; int i = -2; unsigned k = 1; n = i + k;
sign extensions in promotions is something they really should have standardised by now. They haven't even standardised on the binary representation of negative numbers, [...]
Should a high level language be dictating to CPU manufacturers how processors must internally represents values?
1. It already dictates that it must be binary 2. There is really no dictate about the representation. All the standards say it must behave *as if* this is how it's done. A good example is the standard include files, like stdio.h. The standard doesn't dictate that they must be present as regular files, it just dictates that if you have #include <stdio.h> in your program, a certain set of definitions will be assumed to be present, but this can be entirely internal to the compiler if this is deemed to be optimal. Another example is the preprocessor. So just as it is possible to have a strictly conforming implementation on a tertiary machine (where the compiler translates between the binary representation guaranteed by C to the tertiary representation of the hardware), it would be possible to say a negative number should be stored in two's complement with sign extension behaving in a certain way. Just let the compiler hide the gory details