Skip to content

End of Life Ruby 3.1 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →

instance method

BigDecimal#scale

scale → integer

Returns the number of decimal digits following the decimal digits in self.

Example
BigDecimal("0").scale         # => 0
BigDecimal("1").scale         # => 1
BigDecimal("1.1").scale       # => 1
BigDecimal("3.1415").scale    # => 4
BigDecimal("-1e20").precision # => 0
BigDecimal("1e-20").precision # => 20
BigDecimal("Infinity").scale  # => 0
BigDecimal("-Infinity").scale # => 0
BigDecimal("NaN").scale       # => 0
See also #round #sign #remainder #split also in 3.3 · 3.2