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

Split format and format_finite #15

Merged
merged 1 commit into from
Jun 11, 2019
Merged

Split format and format_finite #15

merged 1 commit into from
Jun 11, 2019

Conversation

dtolnay
Copy link
Owner

@dtolnay dtolnay commented Jun 11, 2019

Renames buffer.format(f) to buffer.format_finite(f). Adds buffer.format(f) which can emit "NaN", "inf", "-inf" to match std::fmt.

Fixes #12.

@dtolnay dtolnay merged commit d46f299 into master Jun 11, 2019
@dtolnay dtolnay deleted the cases branch June 11, 2019 19:01
fn is_nonfinite(self) -> bool {
const EXP_MASK: u64 = 0x7ff0000000000000;
let bits = unsafe { mem::transmute::<f64, u64>(self) };
bits & EXP_MASK == EXP_MASK

Choose a reason for hiding this comment

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

Interesting. Does this wind up being faster than !number.f64::is_finite()?

Also, thanks so much for this! :-)

Copy link
Owner Author

Choose a reason for hiding this comment

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

Two things:

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.

checking for NaN/infinity automatically
2 participants