Ruby | BigDecimal class finite? value
BigDecimal#finite?() : finite?() is a BigDecimal class method which checks whether the BigDecimal value is finite.
Syntax: BigDecimal.finite?()
Parameter: BigDecimal values to check
Return: true – if the value is finite; otherwise false
Code #1 : Example for finite?() method
# Ruby code for finite?() method # loading BigDecimalrequire 'bigdecimal' # declaring BigDecimala = 42.1**13 # declaring BigDecimalb = -BigDecimal("10") # declaring BigDecimalc = -(22 ** 7.1) * 10 puts "finite? example 1 : #{a.finite?()}\n\n" puts "finite? example 2 : #{b.finite?()}\n\n" puts "finite? example 3 : #{c.finite?()}\n\n" |
Output :
finite? example 1 : true finite? example 2 : true finite? example 3 : true
Code #2 : Example for finite?() method
# Ruby code for finite?() method # loading BigDecimalrequire 'bigdecimal' # declaring BigDecimalb = BigDecimal('10')-(22 ** 7.1) ** 10 # declaring BigDecimalc = BigDecimal('-3') puts "finite? example 2 : #{b.finite?()}\n\n" puts "finite? example 3 : #{c.finite?()}\n\n" |
Output :
finite? example 2 : true finite? example 3 : true


