Hi
* It seems that addition mentioned in previous mail points out a bug.
* to_d doesnt work -- if also depricated, please update ruby-doc
(if depricated, it should work anyway, shouldnt it?)
*is there a (direct) way to convert Float to BigDecimal?
Thanks
Berg
"doesn't work"?
07:27 ~/testcases/standalone(master)[ruby-2.3.0]$ irb
2.3.0 :001 > require 'bigdecimal'
=> true
2.3.0 :002 > require 'bigdecimal/util'
=> true
2.3.0 :003 > "1.5".to_d
=> #<BigDecimal:7fc02200a390,'0.15E1',18(18)>
2.3.0 :004 > (4/3).to_d
=> #<BigDecimal:7fc0220a2280,'0.1E1',9(27)>
2.3.0 :005 > Float(1.99).to_d
=> #<BigDecimal:7fc022091b38,'0.199E1',18(36)>
2.3.0 :006 >
How does that equate to "doesn't work"?
···
On Sun, Feb 28, 2016 at 12:38 AM, A Berger <aberger7890@gmail.com> wrote:
* It seems that addition mentioned in previous mail points out a bug.
* to_d doesnt work -- if also depricated, please update ruby-doc
(if depricated, it should work anyway, shouldnt it?)
*is there a (direct) way to convert Float to BigDecimal?
--
Hassan Schroeder ------------------------ hassan.schroeder@gmail.com
twitter: @hassan
Consulting Availability : Silicon Valley or remote
hello
Its nowhere stated, that .to_d also needs require .../util !
That should be mentioned in the .to_d paragraph!
ok, now I know why it didnt work...
Berg
% ri .to_d
= .to_d
(from ruby site)
=== Implementation from BigDecimal
···
On Sun, Feb 28, 2016 at 11:13 AM, A Berger <aberger7890@gmail.com> wrote:
Its nowhere stated, that .to_d also needs require .../util !
------------------------------------------------------------------------------
a.to_d -> bigdecimal
------------------------------------------------------------------------------
Returns self.
(from ruby site)
=== Implementation from Float
------------------------------------------------------------------------------
flt.to_d -> bigdecimal
------------------------------------------------------------------------------
Convert flt to a BigDecimal and return it.
require 'bigdecimal'
require 'bigdecimal/util'
0.5.to_d
# => #<BigDecimal:1dc69e0,'0.5E0',9(18)>
(from ruby site)
=== Implementation from Integer
------------------------------------------------------------------------------
int.to_d -> bigdecimal
------------------------------------------------------------------------------
Convert int to a BigDecimal and return it.
require 'bigdecimal'
require 'bigdecimal/util'
: ...
--
Hassan Schroeder ------------------------ hassan.schroeder@gmail.com
twitter: @hassan
Consulting Availability : Silicon Valley or remote