Skip to content

Commit 515978d

Browse files
committed
Use the least significant beat to determine if int/uint is even
1 parent 7bebdbd commit 515978d

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/libstd/num/int_macros.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ impl Integer for $T {
308308

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

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

src/libstd/num/uint_macros.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ impl Integer for $T {
169169

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

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

0 commit comments

Comments
 (0)