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

Integer#to_d

int.to_d → bigdecimal

Returns the value of int as a BigDecimal.

Example
require 'bigdecimal'
require 'bigdecimal/util'

42.to_d   # => 0.42e2

See also BigDecimal::new.

See also #to_bn #to_f #times #to_i also in 3.3 · 3.2 · 3.0