split a big number : BigDecimal « Number « Ruby






split a big number


require 'bigdecimal'

puts BigDecimal("105000").split
# => [1, "105", 10, 6]
# That is, 0.105*(10**6)

puts BigDecimal("-0.005").split
# => [-1, "5", 10, -2]
# That is, -1 * (0.5*(10**-2))

 








Related examples in the same category

1.Big decimal calculation
2.Calculation on BigDecimal in a function
3.precs of BigDecimal
4.Convert big decimal to string
5.to_f cuts numbers
6..to_s("F")
7.Convert BigDecimal to string
8.Add value to BigDecimal
9.Round a BigDecimal
10.Get the square root for a BigDecimal
11.PI in BigDecimal