Project

General

Profile

Actions

Bug #17098

closed

Float#negative? reports negative zero as not negative

Added by chrisseaton (Chris Seaton) over 1 year ago. Updated 6 months ago.

Status:
Rejected
Priority:
Normal
Assignee:
-
Target version:
-
[ruby-core:99426]

Description

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.

Actions

Also available in: Atom PDF