Skip to content

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