Skip to content
Related Articles

Related Articles

Improve Article

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:






# Ruby program of Integer fdiv() function
  
# Initializing the numbers 
num1 = 5
num2 = 2
   
num3 = 9
num4 = 3 
   
# Prints the division 
puts num1.fdiv(num2)
puts num3.fdiv(num4)

Output:

2.5
3.0

Example #2:




# Ruby program of Integer fdiv() function
  
# Initializing the numbers 
num1 = 15
num2 = 4
   
num3 = 10
num4 = 2
   
# Prints the integer division 
puts num1.fdiv(num2)
puts num3.fdiv(num4)

Output:

3.75
5.0
My Personal Notes arrow_drop_up
Recommended Articles
Page :