Numbers

suggest change

Remarks

Numbers hierarchy

Ruby includes several built-in classes to represent numbers:

Numeric
  Integer
  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"

Ruby uses the Integer class for whole numbers of every size. The old Fixnum and Bignum constants were removed in Ruby 2.4.

Feedback about page:

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



Table Of Contents