Open In App

Ruby Float modulo() method with example

Improve
Improve
Like Article
Like
Save
Share
Report

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


Last Updated : 07 Jan, 2020
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads