From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS4713 221.184.0.0/13 X-Spam-Status: No, score=-3.8 required=3.0 tests=AWL,BAYES_00, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from neon.ruby-lang.org (neon.ruby-lang.org [221.186.184.75]) by dcvr.yhbt.net (Postfix) with ESMTP id AA8C51F463 for ; Wed, 25 Sep 2019 11:38:07 +0000 (UTC) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id 5712B120810; Wed, 25 Sep 2019 20:37:59 +0900 (JST) Received: from o1678948x4.outbound-mail.sendgrid.net (o1678948x4.outbound-mail.sendgrid.net [167.89.48.4]) by neon.ruby-lang.org (Postfix) with ESMTPS id 7AFCD120880 for ; Wed, 25 Sep 2019 20:37:54 +0900 (JST) Received: by filter0140p3las1.sendgrid.net with SMTP id filter0140p3las1-5341-5D8B5193-25 2019-09-25 11:37:55.330556044 +0000 UTC m=+145383.081256696 Received: from herokuapp.com (unknown [184.73.122.220]) by ismtpd0090p1iad2.sendgrid.net (SG) with ESMTP id mMbus6EEQm6ab8BwF8YnjA for ; Wed, 25 Sep 2019 11:37:55.201 +0000 (UTC) Date: Wed, 25 Sep 2019 11:37:55 +0000 (UTC) From: nobu@ruby-lang.org Message-ID: References: Mime-Version: 1.0 X-Redmine-MailingListIntegration-Message-Ids: 70639 X-Redmine-Project: ruby-trunk X-Redmine-Issue-Id: 16180 X-Redmine-Issue-Author: BillyRuffian X-Redmine-Sender: nobu X-Mailer: Redmine X-Redmine-Host: bugs.ruby-lang.org X-Redmine-Site: Ruby Issue Tracking System X-Auto-Response-Suppress: All Auto-Submitted: auto-generated X-SG-EID: =?us-ascii?Q?q8Dly+pU2+3ektTtZVXgZtbJPXwqo7p86jCsvYTW4ByLhPxaeMHRdt0KTSIdc3?= =?us-ascii?Q?jCM9fbt6q33qtkzggw3tfeIlzgnPya3VgyfreTq?= =?us-ascii?Q?ZrhsMma8+83AZUtVArb1OZGmLO6dk63Wxmg6Ifk?= =?us-ascii?Q?OQANztBk9ulotBCsicj4tK=2FnzKQ3rvpfqg579P1?= =?us-ascii?Q?3Tafazh40XcbJXfDo5SBGjOmEzAaBP+wt8g=3D=3D?= To: ruby-core@ruby-lang.org X-ML-Name: ruby-core X-Mail-Count: 95084 Subject: [ruby-core:95084] [Ruby master Bug#16180] Random.rand(max) ignores / is broken when max ceiling value is a float X-BeenThere: ruby-core@ruby-lang.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: Ruby developers List-Id: Ruby developers List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ruby-core-bounces@ruby-lang.org Sender: "ruby-core" Issue #16180 has been updated by nobu (Nobuyoshi Nakada). Status changed from Open to Rejected If you want to random `Float` values up to `max`, use `Random#rand` or `Random.rand` instead of `Kernel#rand`. ---------------------------------------- Bug #16180: Random.rand(max) ignores / is broken when max ceiling value is a float https://bugs.ruby-lang.org/issues/16180#change-81716 * Author: BillyRuffian (Nigel Brookes-Thomas) * Status: Rejected * Priority: Normal * Assignee: * Target version: * ruby -v: ruby 2.6.3p62 (2019-04-16 revision 67580) [x86_64-darwin18] * Backport: 2.5: UNKNOWN, 2.6: UNKNOWN ---------------------------------------- ruby 2.6.3p62 (2019-04-16 revision 67580) [x86_64-darwin18] ruby 2.7.0preview1 (2019-05-31 trunk c55db6aa271df4a689dc8eb0039c929bf6ed43ff) [x86_64-darwin18] Calling `rand` with a float of > 1 always return 0. Calling `rand` with a float 0 < value > 1 will ignore the ceiling value. e.g. ``` rand(1.1) => 0 rand(1.1) => 0 rand(0.5) => 0.9501516156613756 rand(0.5) => 0.6864252478379304 ``` -- https://bugs.ruby-lang.org/