Skip to content

Maybe Float::{is_positive, is_negative} should return false for 0's? #22985

Closed
@huonw

Description

@huonw

Over the real numbers, one doesn't usually consider zero to be explicitly positive or negative (one has to qualify as "non-negative" or "non-positive" respectively to get those classes including zero), so it is a little strange to me that we include 0.0 in the former and -0.0 in the latter.

However, floats are special (signed zero), so maybe the current behaviour is OK. I suppose the "real number" behaviour can be replicated with just > 0.0 and >= 0.0, while these functions are checking the IEEE-754 sign bit.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions