红宝石 | BigDecimal 类克隆值
BigDecimal#clone() : clone()是一个 BigDecimal 类方法,它返回 BigDecimal 值的克隆值。
Syntax: BigDecimal.clone()
Parameter: BigDecimal values to find the clone value
Return: clone value for the BigDecimal value
代码 #1:clone() 方法的示例
# Ruby code for clone() method
# loading BigDecimal
require 'bigdecimal'
# declaring BigDecimal
b = -BigDecimal("10")
puts "clone example 2 : #{b.clone()}\n\n"
输出 :
clone example 2 : -0.1E2
代码 #2:clone() 方法的示例
# Ruby code for clone() method
# loading BigDecimal
require 'bigdecimal'
# declaring BigDecimal
b = BigDecimal('10')-(22 ** 7.1) ** 10
# declaring BigDecimal
c = BigDecimal('-3')
puts "clone example 2 : #{b.clone()}\n\n"
puts "clone example 3 : #{c.clone()}\n\n"
输出 :
clone example 2 : -0.20512110073058639999999999999999999999999999999999999999999999999999999999999999999999999999999E96
clone example 3 : -0.3E1