Open In App

Ruby | Numeric fdiv() function

Last Updated : 19 Mar, 2024
Improve
Improve
Like Article
Like
Save
Share
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:




# 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

Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads