Some facts:
- In Ruby there are operators
<<and >>to switch, but there is no built-in rotation operator. You have to fake it. - The Ruby class
Fixnumautomatically advances to Bignumwhen the value exceeds the size of a machine word. This includes numbers that match an unsigned word but not an unsigned word — for example, it 0xffffffffis positive Bignum, not negative Fixnum.
, , , b) 32 64 , Fixnum , c) , .
:
class Integer
def ror count
(self >> count) | (self << (32 - count)) & 0xFFFFFFFF
end
end
>> printf "0x%x\n", (0x01234567.ror 4)
0x70123456