Learn about Ruby Numbers

Learn about Ruby Numbers
0

#1

Basics:

  • Ruby has two categories of numbers - integers and floating-point (also called floats).
  • Integers are whole numbers that can be positive or negative but cannot be fractions.
  • Depending on their size, integers can have the class Fixnum or Bignum.
  • Floats are numbers with a decimal place.

Examples:

x = 5.5
x.class
# returns
Float
x = 5
x.class
# returns
Fixnum
x = 11122233344455566677
x.class
# returns
Bignum # basically, Bignum is a very large number
# [read this article for more info](http://ruby-doc.org/core-2.0.0/Bignum.html)

References:


#2