Robert J. Hansen wrote:
Left shift by negative numbers, will I get 1/2?
Why not try it for yourself? The great virtue of computer science is
that in many ways it's an experimental discipline, not a purely
theoretical one.
this is Really Bad Advice. I you want t to know what a language
construct
is supposed to do then check out a reference. The language standard
itself
is often the best. If you distrust your implementation you may want to
run
a test to verify that your implementation is conforming.
Since "1 << (-1)" has undefined behaviour no amount of empirical
testing
will tell you anything. This weeks test may be invalidated next week by
a
change of platform, compiler version or optimisation settings. In
principal
an implementation could be even worse than that. It may depend on some
obscurity in the hardware.
--
Nick Keighley
Egon: Try to imagine all life as you know it stopping instantaneously
and
every molecule in your body exploding at the speed of light.
Ray: Total protonic reversal....
[DS9000K: Behaviour of Negative Shift]