Open In App

Ruby | BigDecimal class clone value

Improve
Improve
Like Article
Like
Save
Share
Report

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


Last Updated : 08 Jan, 2020
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads