Ruby | BigDecimal class dup value
Last Updated :
08 Jan, 2020
BigDecimal#dup() : dup() is a BigDecimal class method which returns the duplicate value for the BigDecimal value.
Syntax: BigDecimal.dup()
Parameter: BigDecimal values to find the duplicate value
Return: duplicate value for the BigDecimal value
Code #1 : Example for dup() method
require 'bigdecimal'
b = -BigDecimal( "10" )
puts "dup example 2 : #{b.dup()}\n\n"
|
Output :
dup example 2 : -0.1E2
Code #2 : Example for dup() method
require 'bigdecimal'
b = BigDecimal( '10' )-( 22 ** 7 . 1 ) ** 10
c = BigDecimal( '-3' )
puts "dup example 2 : #{b.dup()}\n\n"
puts "dup example 3 : #{c.dup()}\n\n"
|
Output :
dup example 2 : -0.20512110073058639999999999999999999999999999999999999999999999999999999999999999999999999999999E96
dup example 3 : -0.3E1
Share your thoughts in the comments
Please Login to comment...