Open In App

Ruby | Numeric fdiv() function

Last Updated : 12 Jul, 2025
Comments
Improve
Suggest changes
Like Article
Like
Report
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: CPP
# 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: CPP
# Ruby program for fdiv() method in Numeric

# Initialize a number 
num1 = 20

# Prints division of num1/2
puts num1.fdiv(2)
Output:
10.0

Similar Reads