ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / Atom feed
From: marcandre-ruby-core@marc-andre.ca
To: ruby-core@ruby-lang.org
Subject: [ruby-core:99443] [Ruby master Bug#17098] Float#negative? reports negative zero as not negative
Date: Sat, 01 Aug 2020 19:41:08 +0000 (UTC)
Message-ID: <redmine.journal-86898.20200801194108.8671@ruby-lang.org> (raw)
In-Reply-To: <redmine.issue-17098.20200801010523.8671@ruby-lang.org>

Issue #17098 has been updated by marcandre (Marc-Andre Lafortune).


AFAIK, the only way to check for `-0.0` is `1.0 / var == -Float::INFINITY`

I find it difficult to discuss what need to be done about any of this as I do not know of the use cases for `-0.0`; without them it seems very theoretical.

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

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

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-01  1:05 [ruby-core:99426] " chris
2020-08-01  2:18 ` [ruby-core:99427] " merch-redmine
2020-08-01 12:18 ` [ruby-core:99432] " chris
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 ` marcandre-ruby-core [this message]
2020-08-02 12:21 ` [ruby-core:99444] " sawadatsuyoshi

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

ruby-core@ruby-lang.org archive (unofficial mirror)

Archives are clonable: git clone --mirror https://public-inbox.org/ruby-core

Example config snippet for mirrors

Newsgroups are available over NNTP:
	nntp://news.public-inbox.org/inbox.comp.lang.ruby.core
	nntp://ou63pmih66umazou.onion/inbox.comp.lang.ruby.core
	nntp://news.gmane.io/gmane.comp.lang.ruby.core

 note: .onion URLs require Tor: https://www.torproject.org/

AGPL code for this site: git clone https://public-inbox.org/public-inbox.git