mirror of
https://github.com/oliverbooth/X10D
synced 2024-11-10 04:55:42 +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
|
#endif
|
||||||
public static bool IsEven(this byte value)
|
public static bool IsEven(this byte value)
|
||||||
{
|
{
|
||||||
return value % 2 == 0;
|
return (value & 1) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -121,7 +121,7 @@ public static class Int64Extensions
|
|||||||
case <= 3: return true;
|
case <= 3: return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (value % 2 == 0 || value % 3 == 0)
|
if ((value & 1) == 0 || value % 3 == 0)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -79,7 +79,7 @@ public static class SByteExtensions
|
|||||||
#endif
|
#endif
|
||||||
public static bool IsEven(this sbyte value)
|
public static bool IsEven(this sbyte value)
|
||||||
{
|
{
|
||||||
return value % 2 == 0;
|
return (value & 1) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
using System.Diagnostics.Contracts;
|
using System.Diagnostics.Contracts;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
|
|
||||||
namespace X10D.Math;
|
namespace X10D.Math;
|
||||||
@ -97,7 +97,7 @@ public static class UInt64Extensions
|
|||||||
case <= 3: return true;
|
case <= 3: return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (value % 2 == 0 || value % 3 == 0)
|
if ((value & 1) == 0 || value % 3 == 0)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user