Ruby | BigDecimal split() function Last Updated : 06 Dec, 2019 Summarize Comments Improve Suggest changes Share Like Article Like Report 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() method # loading library require 'bigdecimal' # declaring bigdecimal a = BigDecimal("10") # declaring bigdecimal b = -BigDecimal("10") # declaring bigdecimal c = -BigDecimal("11.43") # split() method puts "BigDecimal a split method : #{a.split()}\n\n" puts "BigDecimal b split method : #{b.split()}\n\n" puts "BigDecimal a split method : #{c.split()}\n\n" Output : BigDecimal a split method : [1, "1", 10, 2] BigDecimal b split method : [-1, "1", 10, 2] BigDecimal a split method : [-1, "1143", 10, 2] Example #2 : Ruby # Ruby code for BigDecimal.split() method # loading library require 'bigdecimal' # declaring bigdecimal a = BigDecimal('12')*12 # declaring bigdecimal b = BigDecimal('10')-(22 ** 7.1) ** 10 # declaring bigdecimal c = BigDecimal('-3') # split() method puts "BigDecimal a split method : #{a.split()}\n\n" puts "BigDecimal b split method : #{b.split()}\n\n" puts "BigDecimal a split method : #{c.split()}\n\n" Output : BigDecimal a split method : [1, "144", 10, 3] BigDecimal b split method : [-1, "20512110073058639999999999999999999999999999999999999999999999999999999999999999999999999999999", 10, 96] BigDecimal a split method : [-1, "3", 10, 1] Comment More infoAdvertise with us Next Article Ruby | BigDecimal sqrt() function M mayank5326 Follow Improve Article Tags : Ruby Ruby-Methods Ruby BigDecimal-class Similar Reads Ruby | BigDecimal sign() function 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 requir 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 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 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_r() function BigDecimal#to_r() : to_r() is a BigDecimal class method which returns the value of Big decimal as a rational number. Syntax: BigDecimal.to_r() Parameter: BigDecimal values Return: the value of Big decimal as a rational number Example #1 : Ruby # Ruby code for BigDecimal.to_r() method # loading libra 1 min read Ruby | BigDecimal to_i() function BigDecimal#to_i() : to_i() is a BigDecimal class method which returns the value as an Integer. Syntax: BigDecimal.to_i() Parameter: BigDecimal values Return: the value as an Integer. Example #1 : Ruby # Ruby code for BigDecimal.to_i() method # loading library require 'bigdecimal' require 'bigdecimal 1 min read Like