Open In App

Ruby | BigDecimal class divmod value

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

BigDecimal#divmod() : divmod() is a BigDecimal class method which divided two BigDecimal value.

Syntax: BigDecimal.divmod()

Parameter: BigDecimal values to divide

Return: Quotient and Remainder of the division of two BigDecimal Value

Code #1 : Example for divmod() method




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


Output :

divmod example 1 : [#, #]

divmod example 2 : [#, #]

Code #2 : Example for divmod() method




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


Output :

divmod example 1 : [#, #]

divmod example 2 : [#, #]


Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads