Rational number without using Rational class : Rational Numbers « Number « Ruby
- Ruby
- Number
- Rational Numbers
Rational number without using Rational class
#!/usr/bin/env ruby
require 'rational'
require 'mathn'
rat = Rational(25/100) # => 1/4 -- lowest terms
rat - 1/8 # => 1/8
Related examples in the same category