Skip to content
Related Articles

Related Articles

Ruby Float modulo() method with example
  • Last Updated : 07 Jan, 2020
GeeksforGeeks - Summer Carnival Banner

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






# Ruby program for modulo() method
  
# Initilizig value
a = 26.00
b = 8.0
  
# Printing result
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:




# Ruby code for modulo() method
  
# Initializing value
a = 7.00.numerator()
  
# Printing result
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

Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.

My Personal Notes arrow_drop_up
Recommended Articles
Page :