ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
From: "masasakano (Masa Sakano)" <noreply@ruby-lang.org>
To: ruby-core@ruby-lang.org
Subject: [ruby-core:109826] [Ruby master Bug#18993] Inconsistent Range#size for Float and Rational
Date: Fri, 02 Sep 2022 18:18:04 +0000 (UTC)	[thread overview]
Message-ID: <redmine.issue-18993.20220902181804.52465@ruby-lang.org> (raw)
In-Reply-To: redmine.issue-18993.20220902181804.52465@ruby-lang.org

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/

       reply	other threads:[~2022-09-02 18:18 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-02 18:18 masasakano (Masa Sakano) [this message]
2024-04-09 19:38 ` [ruby-core:117481] [Ruby master Bug#18993] Inconsistent Range#size for Float and Rational jeremyevans0 (Jeremy Evans) via ruby-core

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.ruby-lang.org/en/community/mailing-lists/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=redmine.issue-18993.20220902181804.52465@ruby-lang.org \
    --to=ruby-core@ruby-lang.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).