Ruby | BigDecimal < value
BigDecimal#<() : <() is a BigDecimal class method which compares two BigDecimal values.
Syntax: BigDecimal.<() Parameter: BigDecimal values Return: True - if a < b, otherwise false
Code #1 : Example for <() method
# Ruby code for BigDecimal.<() method # loading BigDecimalrequire 'bigdecimal' # declaring BigDecimala = 42.1**13 # declaring BigDecimalb = -BigDecimal("10") # declaring BigDecimalc = -(22 ** 7.1) * 10 # false - as a>bputs "BigDecimal a < b : #{a<b}\n\n" # false - as b>cputs "BigDecimal b < c : #{b<c}\n\n" # true as a>cputs "BigDecimal a < c : #{c<a}\n\n" |
Output :
BigDecimal a < b : false BigDecimal b < c : false BigDecimal a < c : true
Code #2 : Example for <() method
# Ruby code for BigDecimal.<() method # Loading BigDecimalrequire 'bigdecimal' # declaring BigDecimala = 12**12 - 27 # declaring BigDecimalb = BigDecimal('10')-(22 ** 7.1) ** 10 # declaring BigDecimalc = BigDecimal('-3') # false as a>bputs "BigDecimal a < b : #{a<b}\n\n" # true as b<cputs "BigDecimal b < c : #{b<c}\n\n" |
Output :
BigDecimal a < b : false BigDecimal b < c : true

