📜  Ruby Float quo() 方法与示例

📅  最后修改于: 2022-05-13 01:55:43.406000             🧑  作者: Mango

Ruby Float quo() 方法与示例

Float quo()是一个浮点类方法,它返回除法的商值。

示例 #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