Skip to content

Instantly share code, notes, and snippets.

@2called-chaos
Created January 15, 2016 20:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 2called-chaos/998020a21ab2da4fb787 to your computer and use it in GitHub Desktop.
Save 2called-chaos/998020a21ab2da4fb787 to your computer and use it in GitHub Desktop.
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.
[1] pry(main)> 10.class
=> Fixnum
[2] pry(main)> 10.is_a?(Integer)
=> true
[3] pry(main)> 10.is_a?(Fixnum)
=> true
[4] pry(main)> 10.is_a?(Bignum)
=> false
[5] pry(main)> 999999999999999999999999999999.class
=> Bignum
[6] pry(main)> 999999999999999999999999999999.is_a?(Integer)
=> true
[7] pry(main)> 999999999999999999999999999999.is_a?(Fixnum)
=> false
[8] pry(main)> 999999999999999999999999999999.is_a?(Bignum)
=> true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment