Open In App

Ruby | BigDecimal class clone value

BigDecimal#clone() : clone() is a BigDecimal class method which returns the clone value for the BigDecimal value.

Syntax: BigDecimal.clone()



Parameter: BigDecimal values to find the clone value

Return: clone value for the BigDecimal value



Code #1 : Example for clone() method




# Ruby code for clone() method
  
# loading BigDecimal
require 'bigdecimal'
  
  
# declaring BigDecimal
b = -BigDecimal("10")
  
  
puts "clone example 2 : #{b.clone()}\n\n"
     

Output :

clone example 2 : -0.1E2

Code #2 : Example for clone() method




# 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"

Output :

clone example 2 : -0.20512110073058639999999999999999999999999999999999999999999999999999999999999999999999999999999E96

clone example 3 : -0.3E1

Article Tags :