Keith Thompson wrote On 06/04/07 16:03,:
Mark McIntyre said:
]
How do shifts work on that implementation?
Same as anywhere else. The standard requires them to do what you
expect, but this need not map onto the actual order of bits in memory.
I'm not convinced that the "actual order of bits in memory" is even
meaningful. On systems that don't address bits directly, there may be
no such concept, except perhaps one defined by convention for
documentation purposes.
Agreed. Here's a thought experiment I've suggested
before; perhaps it's a good time to drag it out again.
In the pursuit of ever greater density and ever lower
power consumption, somebody builds a base-four computer
using four-state instead of two-state devices. Integers
on this machine are represented in quartal instead of in
binary, with four-quit bytes, eight-quit shorts, and so on.
However, the manufacturer decided that introducing the
world's first quartal computer would scare off too many
buyers; they'd shake their heads and say "It's too weird
for me" and buy the binary competition. So even though the
machine uses four-state devices the documentation is careful
to conceal this fact: it says (with its fingers crossed)
that the machine operates in binary and (with a straight
face) describes the order of individual bits within various
integer sizes. Since the 1's bit and the 2's bit are in
fact just different aspects of the value of one single quit
this description is largely fantasy, but it's not the first
time a computer manufacturer has lied to you, is it?
Surprisingly enough, I happen to know (by means I am not
at liberty to divulge) that the machine you are using right
at this very moment is a quartal wonder masquerading as a
plain vanilla binary machine. Ask the manufacturer and you'll
get a flat-out denial, but I Happen To Know. On your machine,
the 1's bit and the 2's bit are not neighbors, neither is to
the left or right of the other -- they are in the exact same
place.
With this long-winded setup out of the way, here comes
the experiment itself: Can you devise a C program to test
whether I'm right or wrong about the nature of your machine?
If you cannot, I submit that if C cannot even tell whether
individual bits exist as separable entities, it cannot begin
to tell how these un-isolatable entities are arranged.