红宝石 |数字 quo()函数
quo()是 Ruby 中的一个内置方法,它返回最精确的除法,无论是浮点数还是有理数。
Syntax: num.quo()
Parameters: The function needs a number which is to be checked.
Return Value: It returns the most exact division.
示例 1 :
# Ruby program for quo()
# method in Numeric
# Initialize a number
num1 = 10
num2 = 7
# Prints the quo
puts num1.quo(num2)
输出:
10/7
示例 2 :
# Ruby program for quo()
# method in Numeric
# Initialize a number
num1 = 10
num2 = 5
# Prints the quo
puts num1.quo(num2)
输出:
2/1