Open In App

Ruby | BigDecimal fix class value

Last Updated : 08 Jan, 2020
Improve
Improve
Like Article
Like
Save
Share
Report

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




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


Output :

fix example 2 : -0.1E2

Code #2 : Example for fix() method




# Ruby code for fix() method
  
# loading BigDecimal
require 'bigdecimal'
  
# declaring BigDecimal
b = BigDecimal('10')-(22 ** 7.1) ** 10
  
# declaring BigDecimal
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
Previous
Next
Share your thoughts in the comments

Similar Reads