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
ext/bigdecimal/lib/bigdecimal/util.rb
View on GitHub ↗
# File tmp/rubies/ruby-3.1.3/ext/bigdecimal/lib/bigdecimal/util.rb, line 86
def to_digits
if self.nan? || self.infinite? || self.zero?
self.to_s
else
i = self.to_i.to_s
_,f,_,z = self.frac.split
i + "." + ("0"*(-z)) + f
end
end
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"