Ruby Fixnums are 64-bit on 64-bit rubies:
bits = 8 * 0.size
# => 64
The maximum signed integer under two's complement is 9_223_372_036_854_775_807
, but the maximum Fixnum in Ruby is only half that:
[(1 << 62) - 1, 1 << 62].map(&:class)
# => [Fixnum, Bignum]
max = (1 << 62) - 1
# => 4611686018427387903
max.to_s 2
# => "11111111111111111111111111111111111111111111111111111111111111" (62 bits)
How does Ruby use the missing bit? MRI Fixnum doc only mentions it briefly:
[Fixnum] Holds Integer values that can be represented in a native machine word (minus 1 bit). If any operation on a Fixnum exceeds this range, the value is automatically converted to a Bignum.
Tested with: MRI 2.1.2, JRuby 1.7.13, and Rubinius 2.2.10.