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