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