Open In App

Ruby | BigDecimal precs function

Improve
Improve
Like Article
Like
Save
Share
Report

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]


Last Updated : 05 Dec, 2019
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads