Skip to content
Related Articles

Related Articles

Ruby | Numeric fdiv() function
  • Last Updated : 06 Jan, 2020

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
My Personal Notes arrow_drop_up
Recommended Articles
Page :