November 2001
Intermediate to advanced
218 pages
6h 22m
English
Strings and numbers are the bread and
butter of literals. Ruby provides support for both integers and
floating-point numbers, using classes Fixnum,
Bignum, and Float.
Integers are instances of class
Fixnum or Bignum:
123 # decimal 1_234 # decimal with underline 0377 # octal 0xff # hexadecimal 0b1011 # binary ?a # character code for 'a' 12345678901234567890 # Bignum: an integer of infinite length
Floating-point numbers are instances of class
Float:
123.4 # floating point value 1.0e6 # scientific notation 4E20 # dot not required 4e+20 # sign before exponential
Read now
Unlock full access