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
require 'bigdecimal'
b = -BigDecimal( "10" )
puts "frac example 2 : #{b.frac()}\n\n"
|
Output :
frac example 2 : -0.0
Code #2 : Example for frac() method
require 'bigdecimal'
b = BigDecimal( '10' )-( 22 ** 7 . 1 ) ** 10
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
Share your thoughts in the comments
Please Login to comment...