On Sat, Feb 22, 2003 at 09:27:04PM +0000, nick wrote:
> On Sat, Feb 22, 2003 at 08:44:12PM -0000, Rafael Garcia-Suarez wrote:

> > What undefined behaviour are you referring to exactly ? the shift
> > overrun ? AFAIK it's very predictable (given one int size). Cases of
> 
> Will you accept a shortcut written in perl? The shift op uses C signed
> integers:

Oops. The logical shift uses *un*signed integers, except under use integer

$ perl -MConfig -le 'use integer; print foreach ($^O, $Config{byteorder},  1 << 32)'
linux
1234
0

$ perl -MConfig -le 'use integer; print foreach ($^O, $Config{byteorder},  1 << 32)' 
linux
1234
1

$ perl -MConfig -le 'use integer; print foreach ($^O, $Config{byteorder},  1 << 32)'
linux
4321
0

$ perl -MConfig -le 'use integer; print foreach ($^O, $Config{byteorder},  1 << 32)'
linux
4321
1

So there's actually no difference in the numbers. But as I'm being a pedant I
ought to get the facts right. [I guess it's my fault for drinking Australian
wine :-)]

Nicholas Clark

Reply via email to