Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix float NaN positive/negative assumptions #315

Merged
merged 3 commits into from
Jul 10, 2017

Conversation

PlasmaPower
Copy link
Contributor

These are the minimal assumptions to make about NaN. Fixes part of #312 (but not the next branch).

/// Returns `true` if `self` is positive, including `+0.0` and
/// `Float::infinity()`.
/// Returns `true` if `self` is positive, including `+0.0`,
/// `Float::infinity()`, and `f64::NAN` with newer versions of Rust.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any ideas on how to make this less confusing? Right now it's not clear what "newer versions of Rust" applies to.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NVM ".., and with newer versions of Rust f64::NAN" works.

Copy link
Member

@cuviper cuviper left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's flip those NaN tests so they're on their respective functions.

@@ -337,27 +337,25 @@ pub trait Float
///
/// assert!(f.is_sign_positive());
/// assert!(!g.is_sign_positive());
/// // Requires both tests to determine if is `NaN`
/// assert!(!nan.is_sign_positive() && !nan.is_sign_negative());
/// assert!(!nan.is_sign_negative());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, we should be testing fn is_sign_positive() here, but I realize older rust won't return true. Perhaps this one should check !neg_nan.is_sign_positive().

///
/// let f = 7.0;
/// let g = -7.0;
///
/// assert!(!f.is_sign_negative());
/// assert!(g.is_sign_negative());
/// // Requires both tests to determine if is `NaN`.
/// assert!(!nan.is_sign_positive() && !nan.is_sign_negative());
/// assert!(!neg_nan.is_sign_positive());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And this doctest should have the !nan.is_sign_negative().

@cuviper
Copy link
Member

cuviper commented Jul 10, 2017

Thanks!

I'm not sure if the bot will work since it's not on your branch yet, but let's try:

bors r+

bors bot added a commit that referenced this pull request Jul 10, 2017
315: Fix float NaN positive/negative assumptions r=cuviper

These are the minimal assumptions to make about `NaN`. Fixes part of #312 (but not the `next` branch).
@bors
Copy link
Contributor

bors bot commented Jul 10, 2017

Build succeeded

@bors bors bot merged commit 426034b into rust-num:master Jul 10, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants