Mega Code Archive

 
Categories / Ruby / Number
 

Rational Numbers

A rational number is a number that can be expressed as a fraction of integers.  Ruby supports the use of rational numbers via the Rational class.  To use the Rational class, you must require it in the program.  You create a rational number with the Rational method.  Rational expects you to use integers, by the way.  It will generate errors if you use floats.