Ruby Float modulo() method with example
Float modulo() is a float class method which return the remainder value on dividing two float values.
Syntax: float.modulo()
Parameter: remainder value from the operation p/q
Return: Modulo i.e. Remainder
Example #1: Example for modulo() method
a = 26 . 00
b = 8 . 0
puts "numerator : #{a}\n\n"
puts "Division float/float : #{a.modulo(b)}\n\n"
puts "Division float/float : #{b.modulo(a)}\n\n"
|
Output :
numerator : 26.0
Division float/float : 2.0
Division float/float : 8.0
Example #2:
a = 7 . 00 .numerator()
puts "numerator : #{a}\n\n"
puts "Division float/int : #{a.modulo(4)}\n\n"
puts "Division float/float : #{a.modulo(4.0)}\n\n"
|
Output :
numerator : 7
Division float/int : 3
Division float/float : 3.0
Last Updated :
07 Jan, 2020
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...