Skip to content

Use the least significant beat to determine if int/uint is even #11568

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

Merged
merged 1 commit into from
Jan 16, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/libstd/num/int_macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ impl Integer for $T {

/// Returns `true` if the number is divisible by `2`
#[inline]
fn is_even(&self) -> bool { self.is_multiple_of(&2) }
fn is_even(&self) -> bool { self & 1 == 0 }

/// Returns `true` if the number is not divisible by `2`
#[inline]
Expand Down
2 changes: 1 addition & 1 deletion src/libstd/num/uint_macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ impl Integer for $T {

/// Returns `true` if the number is divisible by `2`
#[inline]
fn is_even(&self) -> bool { self.is_multiple_of(&2) }
fn is_even(&self) -> bool { self & 1 == 0 }

/// Returns `true` if the number is not divisible by `2`
#[inline]
Expand Down