Not clear on whether ksh93's right shift (>>) is arithmetic or logical, as that
may affect the outcome here, but here's what I'm observing:
This is for ksh93 version:
# print ${.sh.version}
Version JM 93u 2011-02-08
Noticing that when we right shift a value, things seem to work right initially:
p110 # print $(( 2**32 >> 31))
2
p110 # print $(( 2**32 >> 32))
1
p110 # print $(( 2**32 >> 33))
0
...
p110 # print $(( 2**32 >> 62 ))
0
p110 # print $(( 2**32 >> 63 ))
0
p110 # print $(( 2**32 >> 64 ))
4294967296
Eh? What's that?
And this continues on again for a while until we hit 97:
p110 # print $(( 2**32 >> 93 ))
8
p110 # print $(( 2**32 >> 94 ))
4
p110 # print $(( 2**32 >> 95 ))
2
p110 # print $(( 2**32 >> 96 ))
1
p110 # print $(( 2**32 >> 97 ))
0
p110 # print $(( 2**32 >> 98 ))
0
Is this signed, or non-integer math, causing this behavior?
To my mind, once you right shift away all your set bits, you should get 0
forever, regardless of how much further you right shift.
Is this a bug, expected behavior, or what?
Thanks!
Gordon Marler
[email protected]
_______________________________________________
ast-users mailing list
[email protected]
http://lists.research.att.com/mailman/listinfo/ast-users