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