Ruby | BigDecimal quo() function

BigDecimal#quo() : quo() is a BigDecimal class method which divides the two BigDecimal values.

Syntax: BigDecimal.quo()

Parameter: BigDecimal values

Return: Divides the two BigDecimal values.

Example #1 : Example for quo() method



filter_none

edit
close

play_arrow

link
brightness_4
code

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

chevron_right


Output :

BigDecimal a quo b : -0.1305170490200644E21

BigDecimal b quo c : 0.294305898374113860903919913595274271160955693E-9

BigDecimal a quo c : -2.603357363878968e-11

Example #2 : Example for quo() method

filter_none

edit
close

play_arrow

link
brightness_4
code

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

chevron_right


Output :

BigDecimal a quo b : -0.43467495135664927751543107109605140241443591953770701070858615126212074067246983224430195700021040971296977257849892016846008052931414945402329722017988217346432784277797794204259881413316908809142E-82

BigDecimal b quo c : 0.68373700243528799999999999999999999999999999999999999999999999999999999999999999999999999999996666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666667E95

BigDecimal a quo c : -0.336469964354864161144849420060934E-12




My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.