diff options
Diffstat (limited to 'ext/bigdecimal')
-rw-r--r-- | ext/bigdecimal/lib/bigdecimal/util.rb | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/ext/bigdecimal/lib/bigdecimal/util.rb b/ext/bigdecimal/lib/bigdecimal/util.rb index 6860cfd702..1ec39a30ee 100644 --- a/ext/bigdecimal/lib/bigdecimal/util.rb +++ b/ext/bigdecimal/lib/bigdecimal/util.rb @@ -1,3 +1,20 @@ +class Integer < Numeric + # call-seq: + # int.to_d -> bigdecimal + # + # Convert +int+ to a BigDecimal and return it. + # + # require 'bigdecimal' + # require 'bigdecimal/util' + # + # 42.to_d + # # => #<BigDecimal:1008ef070,'0.42E2',9(36)> + # + def to_d + BigDecimal(self) + end +end + class Float < Numeric # call-seq: # flt.to_d -> bigdecimal |