* [ruby-core:99170] [Ruby master Bug#17032] BigDecimal .to_d is behaving inconsistent compared to .to_f
@ 2020-07-14 19:56 tilo.sloboda
2020-07-17 21:44 ` [ruby-core:99208] [Ruby master Bug#17032] BigDecimal's `to_d` behaves inconsistent compared to `to_f` merch-redmine
0 siblings, 1 reply; 2+ messages in thread
From: tilo.sloboda @ 2020-07-14 19:56 UTC (permalink / raw
To: ruby-core
Issue #17032 has been reported by TiloS (Tilo S).
----------------------------------------
Bug #17032: BigDecimal .to_d is behaving inconsistent compared to .to_f
https://bugs.ruby-lang.org/issues/17032
* Author: TiloS (Tilo S)
* Status: Open
* Priority: Normal
* ruby -v: 2.5.5
* Backport: 2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: UNKNOWN
----------------------------------------
As a Ruby user I would expect `.to_f` and `.to_d` to behave identically.
Specifically `nil.to_d` should behave like `nil.to_f`
2.5.5 :001 > require 'bigdecimal'
=> true
2.5.5 :002 > require 'bigdecimal/util'
=> true
2.5.5 :003 > nil.to_f
=> 0.0
2.5.5 :004 > nil.to_d
Traceback (most recent call last):
2: from /Users/tsloboda/.rvm/rubies/ruby-2.5.5/bin/irb:11:in `<main>'
1: from (irb):4
NoMethodError (undefined method `to_d' for nil:NilClass)
# users should not have to resort to this:
2.5.5 :005 > nil.to_f.to_d
=> 0.0
--
https://bugs.ruby-lang.org/
^ permalink raw reply [flat|nested] 2+ messages in thread
* [ruby-core:99208] [Ruby master Bug#17032] BigDecimal's `to_d` behaves inconsistent compared to `to_f`
2020-07-14 19:56 [ruby-core:99170] [Ruby master Bug#17032] BigDecimal .to_d is behaving inconsistent compared to .to_f tilo.sloboda
@ 2020-07-17 21:44 ` merch-redmine
0 siblings, 0 replies; 2+ messages in thread
From: merch-redmine @ 2020-07-17 21:44 UTC (permalink / raw
To: ruby-core
Issue #17032 has been updated by jeremyevans0 (Jeremy Evans).
Status changed from Open to Closed
`NilClass#to_d` was added in Ruby 2.6. As it is not security-related (and seems more like a new feature than a bug fix), it will not be backported to Ruby 2.5, as that is in security maintenance mode.
----------------------------------------
Bug #17032: BigDecimal's `to_d` behaves inconsistent compared to `to_f`
https://bugs.ruby-lang.org/issues/17032#change-86586
* Author: TiloS (Tilo S)
* Status: Closed
* Priority: Normal
* ruby -v: 2.5.5
* Backport: 2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: UNKNOWN
----------------------------------------
I would expect `to_f` and `to_d` to behave identically. Specifically, `nil.to_d` should behave like `nil.to_f`.
```ruby
require 'bigdecimal'
require 'bigdecimal/util'
nil.to_f # => 0.0
nil.to_d # >> NoMethodError (undefined method `to_d' for nil:NilClass)
```
Users should not have to resort to this:
```ruby
nil.to_f.to_d # => 0.0
```
--
https://bugs.ruby-lang.org/
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-07-17 21:44 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-07-14 19:56 [ruby-core:99170] [Ruby master Bug#17032] BigDecimal .to_d is behaving inconsistent compared to .to_f tilo.sloboda
2020-07-17 21:44 ` [ruby-core:99208] [Ruby master Bug#17032] BigDecimal's `to_d` behaves inconsistent compared to `to_f` merch-redmine
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).