Ruby BigDecimal类的克隆值
BigDecimal#clone() : clone()是BigDecimal类的一个方法,用于返回BigDecimal值的克隆值。
语法。BigDecimal.clone()
参数。要查找的BigDecimal值的克隆值
返回:BigDecimal值的克隆值
代码#1:clone()方法的例子
# Ruby code for clone() method
# loading BigDecimal
require 'bigdecimal'
# declaring BigDecimal
b = -BigDecimal("10")
puts "clone example 2 : #{b.clone()}\n\n"
```
输出:
```ruby
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.205121100730586399999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999E96
clone example 3 : -0.3E1