Project

General

Profile

Actions

Bug #17098

closed

Float#negative? reports negative zero as not negative

Added by chrisseaton (Chris Seaton) over 3 years ago. Updated almost 3 years ago.

Status:
Rejected
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

Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0