Skip to content
Related Articles

Related Articles

Improve Article

Ruby | BigDecimal precs function

  • Last Updated : 05 Dec, 2019
Geek Week

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 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 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]

My Personal Notes arrow_drop_up
Recommended Articles
Page :