We have looked into many of the data structures that are supported by ruby along with brief examples of their use and structures. Now we turn to the different data types the language supports which is vital in maximizing the potential of Ruby. Numbers are classified into integers and floating point numbers. The handling capabilities of Ruby when it comes to integers is dependent on the amount of memory you have installed on your computer. They are also classified into two object classes stored in either the Fixnum or Bignum classes. Ruby handles conversion to and from these two types automatically and stores them in binary form in their respective classes. Integers can also be used with optional lead signs that denote octal, hex, or binary.
Integer values can also be translated into their ASCII character set equivalents with the use of a ? before the variable. The term numeric literal that is denoted by an exponent or a decimal point is converted into a Float object in correspondence to the native language’s double data type. To obtain the absolute value of an integer you use the form aNumber.abs and not abs(aNumber) as with C and C++.
-
Pages
-
Categories
-
Archives
- March 2010
- February 2010
- January 2010
- December 2009
- November 2009
- October 2009
- September 2009
- August 2009
- July 2009
- June 2009
- May 2009
- April 2009
- March 2009
- February 2009
- January 2009
- December 2008
- November 2008
- October 2008
- September 2008
- August 2008
- July 2008
- June 2008
- May 2008
- April 2008
- March 2008
- February 2008
- January 2008
