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-Status: No, score=-4.0 required=3.0 tests=AWL,BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY 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 177CA1F5AE for ; Sat, 1 Aug 2020 12:50:57 +0000 (UTC) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id 9E8FF120A4B; Sat, 1 Aug 2020 21:50:23 +0900 (JST) Received: from xtrwkhkc.outbound-mail.sendgrid.net (xtrwkhkc.outbound-mail.sendgrid.net [167.89.16.28]) by neon.ruby-lang.org (Postfix) with ESMTPS id D660C120A2D for ; Sat, 1 Aug 2020 21:50:20 +0900 (JST) Received: by filterdrecv-p3iad2-d8cc6d457-bxf2m with SMTP id filterdrecv-p3iad2-d8cc6d457-bxf2m-18-5F256528-40 2020-08-01 12:50:48.643687632 +0000 UTC m=+240150.396891271 Received: from herokuapp.com (unknown) by ismtpd0050p1iad1.sendgrid.net (SG) with ESMTP id jkQpvCylR7agdtRYdwjwGg for ; Sat, 01 Aug 2020 12:50:48.553 +0000 (UTC) Date: Sat, 01 Aug 2020 12:50:48 +0000 (UTC) From: chris@chrisseaton.com Message-ID: References: Mime-Version: 1.0 X-Redmine-MailingListIntegration-Message-Ids: 75263 X-Redmine-Project: ruby-master X-Redmine-Issue-Tracker: Bug X-Redmine-Issue-Id: 17098 X-Redmine-Issue-Author: chrisseaton X-Redmine-Sender: chrisseaton 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?NC3uwXThXFpCxeI+EU+QkxuM4rZrp+UkiX2tCBF1HHuLogf0dcE51KAhUh86Re?= =?us-ascii?Q?9y7Te6l4XlvcFmttgsOo4ZiWwFq+fgf8szEXNgI?= =?us-ascii?Q?4yT2UJAL6QhlM3=2FyMeoRDZcT9nDuoLfc+gWtea=2F?= =?us-ascii?Q?vsXzPrgPmvBc0w9vaE0EfBnNL1otZUvHhFZokti?= =?us-ascii?Q?BfMUh+px5og8qu77etY2XMbn25fo4E8hARk+B8H?= =?us-ascii?Q?oAxl=2FijuDOkdhBtjk=3D?= To: ruby-core@ruby-lang.org X-ML-Name: ruby-core X-Mail-Count: 99434 Subject: [ruby-core:99434] [Ruby master Bug#17098] Float#negative? reports negative zero as not negative 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 #17098 has been updated by chrisseaton (Chris Seaton). My suggestion is that `Float#negative?(neg_zero) == true` and `Float#positive?(pos_zero) == false`. We can't get rid of negative zero - it's a standard part of floating point numbers as implemented by the hardware. It's also useful in some applications. ---------------------------------------- Bug #17098: Float#negative? reports negative zero as not negative https://bugs.ruby-lang.org/issues/17098#change-86887 * Author: chrisseaton (Chris Seaton) * Status: Open * Priority: Normal * Backport: 2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: UNKNOWN ---------------------------------------- Is this intended behaviour? ``` irb(main):001:0> neg_zero = -0.0 => -0.0 irb(main):002:0> neg_zero.negative? => false irb(main):003:0> neg_zero < 0 => false ``` It happens because `Numeric#negative?` uses `< 0`. My understanding of IEEE floating point is that negative zero is not less than zero, but I think it should still report as negative. -- https://bugs.ruby-lang.org/