Skip to content

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

instance method

BigDecimal#sub

sub(p1, p2)

sub(value, digits) -> bigdecimal

Subtract the specified value.

e.g.

Example
c = a.sub(b,n)
digits

If specified and less than the number of significant digits of the result, the result is rounded to that number of digits, according to BigDecimal.mode.

See also #sqrt #to_d #split #to_digits also in 3.3 · 3.1 · 3.0