Luis Masuelli Luis Masuelli - 3 months ago 9
Ruby Question

What is the meaning of this Decimal representation in ruby?

The number is this:

#<BigDecimal:9829250,'0.202499E4',18(27)>


If I print it, it is:
2024.99
. What is the meaning of the
9829250
(perhaps memory address?) and the
18(27)
?

Answer

There's no need to guess when we have documentation for BigDecimal#inspect!

BigDecimal#inspect()

Returns debugging information about the value as a string of comma-separated values in angle brackets with a leading #:

BigDecimal.new("1234.5678").inspect
#=> "#<BigDecimal:b7ea1130,'0.12345678E4',8(12)>"

The first part is the address, the second is the value as a string, and the final part ss(mm) is the current number of significant digits and the maximum number of significant digits, respectively.