Ruby | Numeric fdiv() function
Last Updated :
19 Mar, 2024
The fdiv() is an inbuilt method in Ruby returns the result after performing a float division.
Syntax: num1.fdiv(num2)
Parameters: The function needs two numbers whose float division is to be performed.
Return Value: It returns returns the float division.
Example 1:
# Ruby program for fdiv() method in Numeric
# Initialize a number
num1 = 15
# Prints division of num1/4
puts num1.fdiv(4)
|
Output:
3.75
Example 2:
# Ruby program for fdiv() method in Numeric
# Initialize a number
num1 = 20
# Prints division of num1/2
puts num1.fdiv(2)
|
Output:
10.0
Share your thoughts in the comments
Please Login to comment...