Ruby | BigDecimal sign() function Last Updated : 05 Dec, 2019 Summarize Comments Improve Suggest changes Share Like Article Like Report BigDecimal#sign() : sign() is a BigDecimal class method which signs the Big decimal to the nearest integer. Syntax: BigDecimal.sign() Parameter: BigDecimal values Return: signs the Big decimal to the nearest integer. Example #1 : Ruby # Ruby code for BigDecimal.sign() method # loading library require 'bigdecimal' # declaring bigdecimal a = BigDecimal("10333") # declaring bigdecimal b = -BigDecimal("10") # declaring bigdecimal c = BigDecimal("565") # sign() method puts "BigDecimal example sign : #{a.sign()}\n\n" puts "BigDecimal example sign : #{b.sign()}\n\n" puts "BigDecimal example sign : #{c.sign()}\n\n" Output : BigDecimal example sign : 2 BigDecimal example sign : -2 BigDecimal example sign : 2 Example #2 : Ruby # Ruby code for BigDecimal.sign() method # loading library require 'bigdecimal' # declaring bigdecimal a = BigDecimal('43443') # declaring bigdecimal b = BigDecimal('10') # declaring bigdecimal c = BigDecimal('-3') # sign() method puts "BigDecimal example sign : #{a.sign()}\n\n" puts "BigDecimal example sign : #{b.sign()}\n\n" puts "BigDecimal example sign : #{c.sign()}\n\n" Output : BigDecimal example sign : 2 BigDecimal example sign : 2 BigDecimal example sign : -2 Comment More infoAdvertise with us Next Article Ruby | BigDecimal sign() function M mayank5326 Follow Improve Article Tags : Ruby Ruby-Methods Ruby BigDecimal-class Similar Reads Ruby | BigDecimal sin() function BigDecimal#sin() : sin() is a BigDecimal class method which returns the sine of decimal to the specified number of digits of precision, numeric. Syntax: BigDecimal.sin() Parameter: BigDecimal values Return: the sine of decimal to the specified number of digits of precision, numeric. Example #1 : Rub 2 min read Ruby | BigDecimal split() function BigDecimal#split() : split() is a BigDecimal class method which splits a BigDecimal number into four parts, returned as an array of values. Syntax: BigDecimal.split() Parameter: BigDecimal values Return: - sign - significant_digits - base - exponent Example #1 : Ruby # Ruby code for BigDecimal.split 2 min read Ruby | BigDecimal sub() function BigDecimal#sub() : sub() is a BigDecimal class method which returns the subtraction using a specified value. Syntax: BigDecimal.sub() Parameter: BigDecimal values Return: the subtraction using a specified value. Example #1 : Ruby # Ruby code for BigDecimal.sub() method # loading library require 'big 1 min read Ruby | BigDecimal to_s() function BigDecimal#to_s() : to_s() is a BigDecimal class method which returns the value of Big decimal as a string. Syntax: BigDecimal.to_s() Parameter: BigDecimal values Return: the value of Big decimal as a string. Example #1 : Ruby # Ruby code for BigDecimal.to_s() method # loading library require 'bigde 1 min read Ruby | BigDecimal sqrt() function BigDecimal#sqrt() : sqrt() is a BigDecimal class method which returns the square root of the value. Syntax: BigDecimal.sqrt() Parameter: BigDecimal values Return: the square root of the value. Example #1 : Ruby # Ruby code for BigDecimal.sqrt() method # loading library require 'bigdecimal' # declari 1 min read Like