Ruby | BigDecimal precs function

Last Updated : 5 Dec, 2019
BigDecimal#precs() : precs() is a BigDecimal class method which checks whether the BigDecimal value is nan value.
Syntax: BigDecimal.precs() Parameter: BigDecimal values to check regarding the NaN value. Return: true : if value is a NaN value otherwise return false
Example #1 : Ruby
# Ruby code for precs() method

# loading BigDecimal
require 'bigdecimal'

# declaring BigDecimal
a = BigDecimal('2')

# declaring BigDecimal
b = BigDecimal("100")

# declaring BigDecimal
c = BigDecimal("10 * 20")

# precs() method
puts "precs example 1 : #{a.precs()}\n\n"

puts "precs example 2 : #{b.precs()}\n\n"
Output :
precs example 1 : [9, 18]

precs example 2 : [9, 18]

Example #2 : Ruby
# Ruby code for precs() method

# loading BigDecimal
require 'bigdecimal'

# declaring BigDecimal
c = BigDecimal("10 * 20")

# precs() method
puts "precs example 2 : #{c.precs()}\n\n"
Output :
precs example 2 : [9, 18]

Comment