Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

Ruby | BigDecimal class exponent value

  • Last Updated : 08 Jan, 2020

BigDecimal#exponent() : exponent() is a BigDecimal class method which returns the exponent value for the BigDecimal value.

Syntax: BigDecimal.exponent()

Parameter: BigDecimal values to find the exponent value

Return: exponent value for the BigDecimal value

Code #1 : Example for exponent() method






# Ruby code for exponent() method
  
# loading BigDecimal
require 'bigdecimal'
  
  
# declaring BigDecimal
b = -BigDecimal("10")
  
  
puts "exponent example 2 : #{b.exponent()}\n\n"
     

Output :

exponent example 2 : 2

Code #2 : Example for exponent() method




# Ruby code for exponent() method
  
# loading BigDecimal
require 'bigdecimal'
  
# declaring BigDecimal
b = BigDecimal('10')-(22 ** 7.1) ** 10
  
# declaring BigDecimal
c = BigDecimal('-3')
  
  
puts "exponent example 2 : #{b.exponent()}\n\n"
  
puts "exponent example 3 : #{c.exponent()}\n\n"

Output :

exponent example 2 : 96

exponent example 3 : 1
My Personal Notes arrow_drop_up
Recommended Articles
Page :