From 7a0aae3bd55176d7a56f46caaef6e7ca5e2f8946 Mon Sep 17 00:00:00 2001 From: Oliver Booth Date: Tue, 31 Aug 2021 15:49:43 +0100 Subject: [PATCH] Use bit check rather than modulo for IsEven --- X10D/src/Int16Extensions/Int16Extensions.cs | 2 +- X10D/src/Int32Extensions/Int32Extensions.cs | 2 +- X10D/src/Int64Extensions/Int64Extensions.cs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/X10D/src/Int16Extensions/Int16Extensions.cs b/X10D/src/Int16Extensions/Int16Extensions.cs index 5458e3c..7395943 100644 --- a/X10D/src/Int16Extensions/Int16Extensions.cs +++ b/X10D/src/Int16Extensions/Int16Extensions.cs @@ -66,7 +66,7 @@ namespace X10D /// public static bool IsEven(this short value) { - return value % 2 == 0; + return (value & 1) == 0; } /// diff --git a/X10D/src/Int32Extensions/Int32Extensions.cs b/X10D/src/Int32Extensions/Int32Extensions.cs index f7e66ee..77b6820 100644 --- a/X10D/src/Int32Extensions/Int32Extensions.cs +++ b/X10D/src/Int32Extensions/Int32Extensions.cs @@ -66,7 +66,7 @@ namespace X10D /// public static bool IsEven(this int value) { - return value % 2 == 0; + return (value & 1) == 0; } /// diff --git a/X10D/src/Int64Extensions/Int64Extensions.cs b/X10D/src/Int64Extensions/Int64Extensions.cs index d5d13bd..da43cea 100644 --- a/X10D/src/Int64Extensions/Int64Extensions.cs +++ b/X10D/src/Int64Extensions/Int64Extensions.cs @@ -66,7 +66,7 @@ namespace X10D /// public static bool IsEven(this long value) { - return value % 2 == 0; + return (value & 1) == 0; } ///