mirror of
https://github.com/oliverbooth/X10D
synced 2024-11-12 22:35:43 +00:00
refactor!: move IsEven/IsOdd to NumberExtensions for .net>=7.0
This commit is contained in:
parent
3e0853d102
commit
19c467d88b
@ -78,7 +78,6 @@ public static class ByteExtensions
|
||||
{
|
||||
return (byte)((long)value).GreatestCommonFactor(other);
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Returns a value indicating whether the current value is evenly divisible by 2.
|
||||
@ -109,6 +108,7 @@ public static class ByteExtensions
|
||||
{
|
||||
return !value.IsEven();
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Returns a value indicating whether the current value is a prime number.
|
||||
|
@ -83,7 +83,6 @@ public static class Int16Extensions
|
||||
{
|
||||
return (short)((long)value).GreatestCommonFactor(other);
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Returns a value indicating whether the current value is evenly divisible by 2.
|
||||
@ -114,6 +113,7 @@ public static class Int16Extensions
|
||||
{
|
||||
return !value.IsEven();
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Returns a value indicating whether the current value is a prime number.
|
||||
|
@ -83,7 +83,6 @@ public static class Int32Extensions
|
||||
{
|
||||
return (int)((long)value).GreatestCommonFactor(other);
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Returns a value indicating whether the current value is evenly divisible by 2.
|
||||
@ -114,6 +113,7 @@ public static class Int32Extensions
|
||||
{
|
||||
return !value.IsEven();
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Returns a value indicating whether the current value is a prime number.
|
||||
|
@ -88,7 +88,6 @@ public static class Int64Extensions
|
||||
|
||||
return value;
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Returns a value indicating whether the current value is evenly divisible by 2.
|
||||
@ -119,6 +118,7 @@ public static class Int64Extensions
|
||||
{
|
||||
return !value.IsEven();
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Returns a value indicating whether the current value is a prime number.
|
||||
|
@ -84,7 +84,6 @@ public static class SByteExtensions
|
||||
{
|
||||
return (sbyte)((long)value).GreatestCommonFactor(other);
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Returns a value indicating whether the current value is evenly divisible by 2.
|
||||
@ -115,6 +114,7 @@ public static class SByteExtensions
|
||||
{
|
||||
return !value.IsEven();
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Returns a value indicating whether the current value is a prime number.
|
||||
|
@ -79,7 +79,6 @@ public static class UInt16Extensions
|
||||
{
|
||||
return (ushort)((long)value).GreatestCommonFactor(other);
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Returns a value indicating whether the current value is evenly divisible by 2.
|
||||
@ -96,20 +95,6 @@ public static class UInt16Extensions
|
||||
return (value & 1) == 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a value indicating whether the current value is a prime number.
|
||||
/// </summary>
|
||||
/// <param name="value">The value whose primality to check.</param>
|
||||
/// <returns>
|
||||
/// <see langword="true" /> if <paramref name="value" /> is prime; otherwise, <see langword="false" />.
|
||||
/// </returns>
|
||||
[Pure]
|
||||
[MethodImpl(CompilerResources.MaxOptimization)]
|
||||
public static bool IsPrime(this ushort value)
|
||||
{
|
||||
return ((ulong)value).IsPrime();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a value indicating whether the current value is not evenly divisible by 2.
|
||||
/// </summary>
|
||||
@ -124,6 +109,21 @@ public static class UInt16Extensions
|
||||
{
|
||||
return !value.IsEven();
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Returns a value indicating whether the current value is a prime number.
|
||||
/// </summary>
|
||||
/// <param name="value">The value whose primality to check.</param>
|
||||
/// <returns>
|
||||
/// <see langword="true" /> if <paramref name="value" /> is prime; otherwise, <see langword="false" />.
|
||||
/// </returns>
|
||||
[Pure]
|
||||
[MethodImpl(CompilerResources.MaxOptimization)]
|
||||
public static bool IsPrime(this ushort value)
|
||||
{
|
||||
return ((ulong)value).IsPrime();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Calculates the lowest common multiple between the current 16-bit unsigned integer, and another 16-bit unsigned
|
||||
|
@ -79,7 +79,6 @@ public static class UInt32Extensions
|
||||
{
|
||||
return (uint)((long)value).GreatestCommonFactor(other);
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Returns a value indicating whether the current value is evenly divisible by 2.
|
||||
@ -96,20 +95,6 @@ public static class UInt32Extensions
|
||||
return (value & 1) == 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a value indicating whether the current value is a prime number.
|
||||
/// </summary>
|
||||
/// <param name="value">The value whose primality to check.</param>
|
||||
/// <returns>
|
||||
/// <see langword="true" /> if <paramref name="value" /> is prime; otherwise, <see langword="false" />.
|
||||
/// </returns>
|
||||
[Pure]
|
||||
[MethodImpl(CompilerResources.MaxOptimization)]
|
||||
public static bool IsPrime(this uint value)
|
||||
{
|
||||
return ((ulong)value).IsPrime();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a value indicating whether the current value is not evenly divisible by 2.
|
||||
/// </summary>
|
||||
@ -124,6 +109,21 @@ public static class UInt32Extensions
|
||||
{
|
||||
return !value.IsEven();
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Returns a value indicating whether the current value is a prime number.
|
||||
/// </summary>
|
||||
/// <param name="value">The value whose primality to check.</param>
|
||||
/// <returns>
|
||||
/// <see langword="true" /> if <paramref name="value" /> is prime; otherwise, <see langword="false" />.
|
||||
/// </returns>
|
||||
[Pure]
|
||||
[MethodImpl(CompilerResources.MaxOptimization)]
|
||||
public static bool IsPrime(this uint value)
|
||||
{
|
||||
return ((ulong)value).IsPrime();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Calculates the lowest common multiple between the current 32-bit unsigned integer, and another 32-bit unsigned
|
||||
|
@ -84,7 +84,6 @@ public static class UInt64Extensions
|
||||
|
||||
return value;
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Returns a value indicating whether the current value is evenly divisible by 2.
|
||||
@ -101,6 +100,22 @@ public static class UInt64Extensions
|
||||
return (value & 1) == 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a value indicating whether the current value is not evenly divisible by 2.
|
||||
/// </summary>
|
||||
/// <param name="value">The value whose parity to check.</param>
|
||||
/// <returns>
|
||||
/// <see langword="true" /> if <paramref name="value" /> is not evenly divisible by 2, or <see langword="false" />
|
||||
/// otherwise.
|
||||
/// </returns>
|
||||
[Pure]
|
||||
[MethodImpl(CompilerResources.MaxOptimization)]
|
||||
public static bool IsOdd(this ulong value)
|
||||
{
|
||||
return !value.IsEven();
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Returns a value indicating whether the current value is a prime number.
|
||||
/// </summary>
|
||||
@ -134,21 +149,6 @@ public static class UInt64Extensions
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a value indicating whether the current value is not evenly divisible by 2.
|
||||
/// </summary>
|
||||
/// <param name="value">The value whose parity to check.</param>
|
||||
/// <returns>
|
||||
/// <see langword="true" /> if <paramref name="value" /> is not evenly divisible by 2, or <see langword="false" />
|
||||
/// otherwise.
|
||||
/// </returns>
|
||||
[Pure]
|
||||
[MethodImpl(CompilerResources.MaxOptimization)]
|
||||
public static bool IsOdd(this ulong value)
|
||||
{
|
||||
return !value.IsEven();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Calculates the lowest common multiple between the current 64-bit unsigned integer, and another 64-bit unsigned
|
||||
/// integer.
|
||||
|
Loading…
Reference in New Issue
Block a user