Open In App

Ruby | Numeric quo() function

Last Updated : 19 Mar, 2024
Improve
Improve
Like Article
Like
Save
Share
Report

The quo() is an inbuilt method in Ruby returns the most exact division, whether it be a float or a rational one.

Syntax: num.quo()

Parameters: The function needs a number which is to be checked.

Return Value: It returns the most exact division.

Example 1:




# Ruby program for quo()
# method in Numeric
  
# Initialize a number 
num1 = 10
num2 = 7
  
# Prints the quo
puts num1.quo(num2)


Output:

10/7

Example 2:




# Ruby program for quo()
# method in Numeric
  
# Initialize a number 
num1 = 10
num2 = 5
  
# Prints the quo
puts num1.quo(num2)


Output:

2/1

Similar Reads

Ruby | BigDecimal quo() function
BigDecimal#quo() : quo() is a BigDecimal class method which divides the two BigDecimal values. Syntax: BigDecimal.quo() Parameter: BigDecimal values Return: Divides the two BigDecimal values. Example #1 : Example for quo() method # Ruby code for BigDecimal.quo() method # loading library require 'bigdecimal' # declaring bigdecimal a = 42.1**13 # dec
2 min read
Ruby | Rational quo() function
The quo() is an inbuilt function in Ruby returns the rational number by performing division. Syntax: rat1.quo(rat2) Parameters: The function accepts a single parameter Return Value: It returns the rational number by performing division Example 1: # Ruby program for quo() method # Initialize rational number rat1 = Rational(-2, 9) rat2 = Rational(-9,
1 min read
Ruby Float quo() method with example
Float quo() is a float class method which return the quotient value of the division. Syntax: float.quo() Parameter: float values - dividend and divisor Return: Quotient value of the division. Example #1: # Ruby code for quo() method # Initializing value a = 4.0 b = 2.0 # Printing result puts "Division a/b : #{a.quo(b)}\n\n" puts "Div
1 min read
Ruby | Numeric modulo() function
The modulo() is an inbuilt method in Ruby returns the modular value when two numbers are divided. It returns the value of a modulo b. Syntax: a.modulo(b) Parameters: The function needs two number whose modulus on division is returned. Return Value: It returns the modulus when two numbers are divided. Example 1: # Ruby program for % method in Matrix
1 min read
Ruby | Numeric divmod() function
The divmod() is an inbuilt method in Ruby returns the integer quotient and modulus after performing the division. Syntax: num1.divmod(num2) Parameters: The function needs two numbers whose integer division is to be performed. Return Value: It returns returns the integer quotient and modulus after performing the division..Example 1: [GFGTABS] CPP #R
1 min read
Ruby | Numeric div() function
The div() is an inbuilt method in Ruby that returns the result after performing an integer division. Syntax: num1.div(num2) Parameters: The function needs two numbers whose integer division is to be performed. Return Value: It returns returns the integer division.Example 1: [GFGTABS] CPP #Ruby program for div() method in Matrix #Initialize a number
1 min read
Ruby | Numeric denominator() function
The denominator() is an inbuilt method in Ruby returns the denominator of the number. Syntax: num1.denominator() Parameters: The function needs a number whose denominator is returned. Return Value: It returns itself only. Example 1: # Ruby program for denominator() method in Matrix # Initialize a number num1 = 1.5 # Function used num = num1.denomin
1 min read
Ruby | Numeric conjugate() function
The conjugate() is an inbuilt method in Ruby returns the number itself. Syntax: num1.conjugate() Parameters: The function needs a number. Return Value: It returns itself only. Example 1: # Ruby program for conjugate() method in Matrix # Initialize a number num1 = 1.7 # Function used num = num1.conjugate() # Prints conjugate() of num puts num Output
1 min read
Ruby | Numeric conj() function
The conj() is an inbuilt method in Ruby returns the number itself. Syntax: num1.conj() Parameters: The function needs a number. Return Value: It returns itself only. Example 1: C/C++ Code # Ruby program for conj() method in Numeric # Initialize a number num1 = 1.7 # Function used num = num1.conj() # Prints conj() of num puts num Output: 1.7 Example
1 min read
Ruby | Numeric coerce() function
The coerce() is an inbuilt method in Ruby returns an array containing two numbers containing two float numbers. Syntax: num1.coerce(num2) Parameters: The function needs a number and ndigits to which the precision of decimal digits is kept. In case no ndigits is passed it takes 0 to be the default value. Return Value: It returns the smallest number
1 min read