Fixnum literal value : Fixnum class « Number « Ruby






Fixnum literal value


123456                   => 123456   # Fixnum
0d123456                 => 123456   # Fixnum
123_456                  => 123456   # Fixnum - underscore ignored
-543                     => -543     # Fixnum - negative number
0xaabb                   => 43707    # Fixnum - hexadecimal
0377                     => 255      # Fixnum - octal
-0b10_1010               => -42      # Fixnum - binary (negated)
123_456_789_123_456_789  => 123456789123456789 # Bignum

 








Related examples in the same category

1.Normal-looking math equations when you use operator methods, such as +
2.Extend the Fixnum class with some helper methods to make manipulating dates easier
3.Output the modules where Fixnum lives
4.find out the ancestors of Fixnum
5.Raise ArgumentError from method