[#104307] Float truncate — Eustáquio Rangel <eustaquiorangel@...>
Hi!
4 messages
2021/06/16
[ruby-core:104268] [Ruby master Bug#17098] Float#negative? reports negative zero as not negative
From:
muraken@...
Date:
2021-06-15 05:05:21 UTC
List:
ruby-core #104268
Issue #17098 has been updated by mrkn (Kenta Murata). If you have pragmatic demands that need to distinguish `-0.0` and `+0.0`, what do you think to propose the introduction of `Float#signbit`? ---------------------------------------- Bug #17098: Float#negative? reports negative zero as not negative https://bugs.ruby-lang.org/issues/17098#change-92478 * 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:[email protected]?subject=unsubscribe> <http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>