Ruby | BigDecimal class frac value
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
Contact Us