mirror of
https://github.com/oliverbooth/X10D
synced 2024-11-22 01:58:47 +00:00
refactor!: move GCF to BinaryIntegerExtensions for .net>=7
This commit is contained in:
parent
30f158e861
commit
3e0853d102
@ -78,5 +78,24 @@ public static class BinaryIntegerExtensions
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Calculates the greatest common factor between the current binary integer, and another binary integer.
|
||||
/// </summary>
|
||||
/// <param name="value">The first value.</param>
|
||||
/// <param name="other">The second value.</param>
|
||||
/// <returns>The greatest common factor between <paramref name="value" /> and <paramref name="other" />.</returns>
|
||||
[Pure]
|
||||
[MethodImpl(CompilerResources.MaxOptimization)]
|
||||
public static TInteger GreatestCommonFactor<TInteger>(this TInteger value, TInteger other)
|
||||
where TInteger : IBinaryInteger<TInteger>
|
||||
{
|
||||
while (other != TInteger.Zero)
|
||||
{
|
||||
(value, other) = (other, value % other);
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -65,7 +65,6 @@ public static class ByteExtensions
|
||||
|
||||
return result;
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Calculates the greatest common factor between the current 8-bit unsigned integer, and another 8-bit unsigned integer.
|
||||
@ -79,6 +78,7 @@ 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.
|
||||
|
@ -70,7 +70,6 @@ public static class Int16Extensions
|
||||
|
||||
return result;
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Calculates the greatest common factor between the current 16-bit signed integer, and another 16-bit signed integer.
|
||||
@ -84,6 +83,7 @@ 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.
|
||||
|
@ -70,7 +70,6 @@ public static class Int32Extensions
|
||||
|
||||
return result;
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Calculates the greatest common factor between the current 32-bit signed integer, and another 32-bit signed integer.
|
||||
@ -84,6 +83,7 @@ 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.
|
||||
|
@ -70,7 +70,6 @@ public static class Int64Extensions
|
||||
|
||||
return result;
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Calculates the greatest common factor between the current 64-bit signed integer, and another 64-bit unsigned integer.
|
||||
@ -89,6 +88,7 @@ public static class Int64Extensions
|
||||
|
||||
return value;
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Returns a value indicating whether the current value is evenly divisible by 2.
|
||||
|
@ -71,7 +71,6 @@ public static class SByteExtensions
|
||||
|
||||
return result;
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Calculates the greatest common factor between the current 8-bit signed integer, and another 8-bit signed integer.
|
||||
@ -85,6 +84,7 @@ 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.
|
||||
|
@ -65,7 +65,6 @@ public static class UInt16Extensions
|
||||
|
||||
return result;
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Calculates the greatest common factor between the current 16-bit unsigned integer, and another 16-bit unsigned
|
||||
@ -80,6 +79,7 @@ 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.
|
||||
|
@ -65,7 +65,6 @@ public static class UInt32Extensions
|
||||
|
||||
return result;
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Calculates the greatest common factor between the current 32-bit unsigned integer, and another 32-bit unsigned
|
||||
@ -80,6 +79,7 @@ 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.
|
||||
|
@ -65,7 +65,6 @@ public static class UInt64Extensions
|
||||
|
||||
return result;
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Calculates the greatest common factor between the current 64-bit unsigned integer, and another 64-bit unsigned
|
||||
@ -85,6 +84,7 @@ public static class UInt64Extensions
|
||||
|
||||
return value;
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Returns a value indicating whether the current value is evenly divisible by 2.
|
||||
|
Loading…
Reference in New Issue
Block a user