From: matz@... Date: 2021-06-17T05:47:59+00:00 Subject: [ruby-core:104332] [Ruby master Bug#17098] Float#negative? reports negative zero as not negative Issue #17098 has been updated by matz (Yukihiro Matsumoto). Unless there's any particular (real-world) reason to distinguish floating positive zero and negative zero, I'd like to keep the current behavior. And as @mrkn suggested, `Float#sign` may be useful to distinguish those two zeros, but it should be discussed as a different proposal. Matz. ---------------------------------------- Bug #17098: Float#negative? reports negative zero as not negative https://bugs.ruby-lang.org/issues/17098#change-92552 * 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: