Skip to content

Instantly share code, notes, and snippets.

@ahoward
Created April 18, 2011 19:30
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ahoward/926001 to your computer and use it in GitHub Desktop.
Save ahoward/926001 to your computer and use it in GitHub Desktop.
class Fixnum
LONG_MAX = ( (2 ** (64 - 2)) - 1 )
INT_MAX = ( (2 ** (32 - 2)) - 1 )
if LONG_MAX.class == Fixnum
N_BYTES = 8
N_BITS = 64
MAX = LONG_MAX
MIN = -MAX - 1
else
N_BYTES = 4
N_BITS = 32
MAX = INT_MAX
MIN = -MAX - 1
end
def Fixnum.max() MAX end
def Fixnum.min() MIN end
raise('bad Fixnum.max') unless (Fixnum.max + 1).class == Bignum
end
if $0 == __FILE__
p Fixnum.max
p Fixnum.min
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment