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/

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>