On 02/21/2015 02:38 AM, Sean Conner wrote:
Given the defined ranges, and the fact that signed
overflow is undefined
behavior, I think C can be used on sign-magnitude and 1's complement
machines (however few those are). Unsigned overflow is defined to wrap
around to 0.
You miss my point, I think. I'll try again.
Consider a machine with a word length of 64 bits. This machine
represents floating point numbers with a 16 bit exponent and a 48 bit
mantissa (nothing unusual so far).
So we have the length of short = int = long = 64 bits. So far so good.
However, given such a generous word length, the designers of this
machine decide not to dedicate special hardware toward handling 64 bit
integers, but have said that 48 bits should be long enough for anyone,
and so treat integer arithmetic as a subset of floating point
(straightforward enough). So not all values of a 64 bit word reflect
valid integers--the exponent must be a certain value--anything else is
floating point.
Now, here's where we get into sticky territory. Since C draws no data
type distinctions between bitwise logical operations on ints and
arithmetic operations, is it possible to implement C on this machine?
It should be obvious that bitwise logical operations on a 64 bit int,
whose upper 16 bits must conform to a special case of a float, that all
logical operations on an int do not result in legal int values.
-------------------
As far as "bytes" on systems, perhaps the attribute of byte
addressability makes sense on short word-length machines, but I don't
believe that it's necessary for longer word length machines. A decent
set of shifting and masking primitives operating on whole words has been
known to work as well, and in some cases better than a machine that
dedicates hardware toward addressing sub-word-length items. I think
byte addressing is more a matter of functional fixedness more than
anything else.
--Chuck