Mega Code Archive

 
Categories / Ruby / Number
 

Modulo two rational numbers

#!/usr/bin/env ruby require 'rational' require 'mathn' rat = Rational(25/100) # => 1/4 -- lowest terms rat % Rational(1/2) # => 1/4 -- modulo or remainder