Open In App

Ruby | BigDecimal class exponent value

Last Updated : 08 Jan, 2020
Improve
Improve
Like Article
Like
Save
Share
Report

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

Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads