Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

Ruby | BigDecimal class frac value

  • Last Updated : 08 Jan, 2020

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

Syntax: BigDecimal.frac()

Parameter: BigDecimal values to find the fractional part of the value

Return: integer value for the BigDecimal value

Code #1 : Example for frac() method






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

Output :

frac example 2 : -0.0

Code #2 : Example for frac() method




# Ruby code for frac() method
  
# loading BigDecimal
require 'bigdecimal'
  
# declaring BigDecimal
b = BigDecimal('10')-(22 ** 7.1) ** 10
  
# declaring BigDecimal
c = BigDecimal('-3')
  
  
puts "frac example 2 : #{b.frac()}\n\n"
  
puts "frac example 3 : #{c.frac()}\n\n"

Output :

frac example 2 : -0.0

frac example 3 : -0.0
My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!