Skip to content

Maintenance Ruby 3.3 gets fixes, but no new features. 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.2 · 3.1 · 3.0