ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
From: chris@chrisseaton.com
To: ruby-core@ruby-lang.org
Subject: [ruby-core:99432] [Ruby master Bug#17098] Float#negative? reports negative zero as not negative
Date: Sat, 01 Aug 2020 12:18:08 +0000 (UTC)	[thread overview]
Message-ID: <redmine.journal-86885.20200801121807.8671@ruby-lang.org> (raw)
In-Reply-To: redmine.issue-17098.20200801010523.8671@ruby-lang.org

Issue #17098 has been updated by chrisseaton (Chris Seaton).


It's already the case that `neg_zero == pos_zero` but not all methods on the two returns the same result - for example `neg_zero.inspect != pos_zero.inspect`.

----------------------------------------
Bug #17098: Float#negative? reports negative zero as not negative
https://bugs.ruby-lang.org/issues/17098#change-86885

* 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/

  parent reply	other threads:[~2020-08-01 12:18 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-01  1:05 [ruby-core:99426] [Ruby master Bug#17098] Float#negative? reports negative zero as not negative chris
2020-08-01  2:18 ` [ruby-core:99427] " merch-redmine
2020-08-01 12:18 ` chris [this message]
2020-08-01 12:38 ` [ruby-core:99433] " sawadatsuyoshi
2020-08-01 12:50 ` [ruby-core:99434] " chris
2020-08-01 16:00 ` [ruby-core:99441] " chris
2020-08-01 18:02 ` [ruby-core:99442] " eregontp
2020-08-01 19:41 ` [ruby-core:99443] " marcandre-ruby-core
2020-08-02 12:21 ` [ruby-core:99444] " sawadatsuyoshi
2021-06-15  4:58 ` [ruby-core:104267] " muraken
2021-06-15  5:05 ` [ruby-core:104268] " muraken
2021-06-17  5:47 ` [ruby-core:104332] " matz

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.journal-86885.20200801121807.8671@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).