Ruby | BigDecimal class divmod value
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 BigDecimalrequire 'bigdecimal' # declaring BigDecimala = 42.1**13 # declaring BigDecimalb = -BigDecimal("10") # declaring BigDecimalc = -(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 BigDecimalrequire 'bigdecimal' # declaring BigDecimala = 12**12 - 27 # declaring BigDecimalb = BigDecimal('10')-(22 ** 7.1) ** 10 # declaring BigDecimalc = 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 : [#, #]





Please Login to comment...