mirror of
https://github.com/oliverbooth/X10D
synced 2024-11-10 03:45:41 +00:00
Use n&1 rather than n%2 for integer IsEven check
This commit is contained in:
parent
941f3acc56
commit
a53cb12d5d
@ -73,7 +73,7 @@ public static class ByteExtensions
|
||||
#endif
|
||||
public static bool IsEven(this byte value)
|
||||
{
|
||||
return value % 2 == 0;
|
||||
return (value & 1) == 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -121,7 +121,7 @@ public static class Int64Extensions
|
||||
case <= 3: return true;
|
||||
}
|
||||
|
||||
if (value % 2 == 0 || value % 3 == 0)
|
||||
if ((value & 1) == 0 || value % 3 == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -79,7 +79,7 @@ public static class SByteExtensions
|
||||
#endif
|
||||
public static bool IsEven(this sbyte value)
|
||||
{
|
||||
return value % 2 == 0;
|
||||
return (value & 1) == 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -1,4 +1,4 @@
|
||||
using System.Diagnostics.Contracts;
|
||||
using System.Diagnostics.Contracts;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace X10D.Math;
|
||||
@ -97,7 +97,7 @@ public static class UInt64Extensions
|
||||
case <= 3: return true;
|
||||
}
|
||||
|
||||
if (value % 2 == 0 || value % 3 == 0)
|
||||
if ((value & 1) == 0 || value % 3 == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user