Ruby Float quo() 方法与示例
Float quo()是一个浮点类方法,它返回除法的商值。
Syntax: float.quo()
Parameter: float values – dividend and divisor
Return: Quotient value of the division.
示例 #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 "Division b/a : #{b.quo(a)}\n\n"
输出 :
Division a/b : 2.0
Division b/a : 0.5
示例 #2:
# Ruby code for quo() method
# Initializing value
a = 0
b = 2.0
# Printing result
puts "Division a/b : #{a.quo(b)}\n\n"
puts "Division b/a : #{b.quo(a)}\n\n"
输出 :
Division a/b : 0.0
Division b/a : Infinity