ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
* [ruby-core:109826] [Ruby master Bug#18993] Inconsistent Range#size for Float and Rational
@ 2022-09-02 18:18 masasakano (Masa Sakano)
  2024-04-09 19:38 ` [ruby-core:117481] " jeremyevans0 (Jeremy Evans) via ruby-core
  0 siblings, 1 reply; 2+ messages in thread
From: masasakano (Masa Sakano) @ 2022-09-02 18:18 UTC (permalink / raw)
  To: ruby-core

Issue #18993 has been reported by masasakano (Masa Sakano).

----------------------------------------
Bug #18993: Inconsistent Range#size for Float and Rational
https://bugs.ruby-lang.org/issues/18993

* Author: masasakano (Masa Sakano)
* Status: Open
* Priority: Normal
* ruby -v: ruby 3.1.2p20 (2022-04-12 revision 4491bb740a) [x86_64-darwin20]
* Backport: 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN
----------------------------------------
The returned values of Range#size between Rational and Float and also with regard to `exclude_end` of true and false are inconsistent.

The example below highlights the difference. The first and second should return the same value. The difference between the first and third seems strange - if this is the specification, it should be clearly described in the [doc](https://ruby-doc.org/core-3.1.2/Range.html#method-i-size "Ruby-3.1.2 official doc of Range"). This point may be related to the issue "Misc #18984".

```ruby
(5.quo(3)...5).size      # => 3
(5.quo(3).to_f...5).size # => 4
(5.quo(3)..5).size       # => 4
(5.quo(3).to_f..5).size  # => 4
```





-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [ruby-core:117481] [Ruby master Bug#18993] Inconsistent Range#size for Float and Rational
  2022-09-02 18:18 [ruby-core:109826] [Ruby master Bug#18993] Inconsistent Range#size for Float and Rational masasakano (Masa Sakano)
@ 2024-04-09 19:38 ` jeremyevans0 (Jeremy Evans) via ruby-core
  0 siblings, 0 replies; 2+ messages in thread
From: jeremyevans0 (Jeremy Evans) via ruby-core @ 2024-04-09 19:38 UTC (permalink / raw)
  To: ruby-core; +Cc: jeremyevans0 (Jeremy Evans)

Issue #18993 has been updated by jeremyevans0 (Jeremy Evans).

Status changed from Open to Closed

This appears fixed in Ruby 3.3:

```
$ ruby32 -ve "p (5.quo(3)...5).size"
ruby 3.2.3 (2024-01-18 revision 52bb2ac0a6) [x86_64-openbsd]
3

$ ruby33 -ve "p (5.quo(3)...5).size"
ruby 3.3.0 (2023-12-25 revision 5124f9ac75) [x86_64-openbsd]
4
```

----------------------------------------
Bug #18993: Inconsistent Range#size for Float and Rational
https://bugs.ruby-lang.org/issues/18993#change-107868

* Author: masasakano (Masa Sakano)
* Status: Closed
* ruby -v: ruby 3.1.2p20 (2022-04-12 revision 4491bb740a) [x86_64-darwin20]
* Backport: 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN
----------------------------------------
The returned values of Range#size between Rational and Float and also with regard to `exclude_end` of true and false are inconsistent.

The example below highlights the difference. The first and second should return the same value. The difference between the first and third seems strange - if this is the specification, it should be clearly described in the [doc](https://ruby-doc.org/core-3.1.2/Range.html#method-i-size "Ruby-3.1.2 official doc of Range"). This point may be related to the issue "Misc #18984".

```ruby
(5.quo(3)...5).size      # => 3
(5.quo(3).to_f...5).size # => 4
(5.quo(3)..5).size       # => 4
(5.quo(3).to_f..5).size  # => 4
```





-- 
https://bugs.ruby-lang.org/
 ______________________________________________
 ruby-core mailing list -- ruby-core@ml.ruby-lang.org
 To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
 ruby-core info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.org/

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-04-09 19:38 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-02 18:18 [ruby-core:109826] [Ruby master Bug#18993] Inconsistent Range#size for Float and Rational masasakano (Masa Sakano)
2024-04-09 19:38 ` [ruby-core:117481] " jeremyevans0 (Jeremy Evans) via ruby-core

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).