Numbers

suggest change

Remarks

Numbers hierarchy

Ruby includes several built-in classes to represent numbers:

Numeric
  Integer
    Fixnum    # 1
    Bignum    # 10000000000000000000
  Float       # 1.0
  Complex     # (1+0i)
  Rational    # Rational(2, 3) == 2/3
  BigDecimal  # not loaded by default

The most common are:

BigDecimal is the only one not loaded by default. You can load it with:

require "bigdecimal"

Note that in ruby 2.4+, Fixnum and Bignum are unified; all integers are now just members of the Integer class. For backwards compatibility, Fixnum == Bignum == Integer.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents