Horje
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




# 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




Reffered: https://www.geeksforgeeks.org


Ruby

Related
Ruby Float nan?() method with example Ruby Float nan?() method with example
Ruby Float next_float() method with example Ruby Float next_float() method with example
Ruby Float prev_float() method with example Ruby Float prev_float() method with example
Ruby Float quo() method with example Ruby Float quo() method with example
Ruby Float rationalize() method with example Ruby Float rationalize() method with example

Type:
Geek
Category:
Coding
Sub Category:
Tutorial
Uploaded by:
Admin
Views:
9