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#to_digits

a.to_digits → string

Converts a BigDecimal to a String of the form “nnnnnn.mmm”. This method is deprecated; use BigDecimal#to_s(“F”) instead.

Example
require 'bigdecimal/util'

d = BigDecimal("3.14")
d.to_digits                  # => "3.14"
See also #to_d #to_f #sub #to_i also in 3.3 · 3.2 · 3.0