Ruby Integer fdiv() function with example
Last Updated :
24 Jun, 2020
The fdiv() function in Ruby returns the floating point result after division of two numbers.
Syntax: (number1).fdiv(number2)
Parameter: The function needs two numbers number1 and number2, where number1 is the dividend and number2 is the divisor.
Return Value: The function returns the floating point division of two numbers.
Example #1:
num1 = 5
num2 = 2
num3 = 9
num4 = 3
puts num1.fdiv(num2)
puts num3.fdiv(num4)
|
Output:
2.5
3.0
Example #2:
num1 = 15
num2 = 4
num3 = 10
num4 = 2
puts num1.fdiv(num2)
puts num3.fdiv(num4)
|
Output:
3.75
5.0
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...