diff --git a/CHANGELOG.md b/CHANGELOG.md index 43469b0c1..ada6f5447 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - X10D: Removed `IEnumerable.LowestCommonMultiple` for all integer types in favour of generic math. - X10D: Removed `IEnumerable.Product` for all integer types in favour of generic math. - X10D: Removed `IEnumerable.RangeTo` for all integer types in favour of generic math. +- X10D: Removed `T.Saturate` for all floating-point types in favour of generic math. - X10D: Removed `T.Sign` for all numeric types in favour of generic math. - X10D: Removed `T.Wrap` for all numeric types in favour of generic math. diff --git a/X10D/src/Math/DecimalExtensions.cs b/X10D/src/Math/DecimalExtensions.cs index 07db13d93..af1a9ed39 100644 --- a/X10D/src/Math/DecimalExtensions.cs +++ b/X10D/src/Math/DecimalExtensions.cs @@ -77,19 +77,6 @@ public static decimal Round(this decimal value, decimal nearest) return System.Math.Round(value / nearest) * nearest; } - /// - /// Saturates this decimal number. - /// - /// The value to saturate. - /// The saturated value. - /// This method clamps between 0 and 1. - [Pure] - [MethodImpl(CompilerResources.MaxOptimization)] - public static decimal Saturate(this decimal value) - { - return System.Math.Clamp(value, 0.0m, 1.0m); - } - /// /// Returns the square root of this decimal number. /// diff --git a/X10D/src/Math/DoubleExtensions.cs b/X10D/src/Math/DoubleExtensions.cs index 0ca716c08..33ee4813c 100644 --- a/X10D/src/Math/DoubleExtensions.cs +++ b/X10D/src/Math/DoubleExtensions.cs @@ -255,19 +255,6 @@ public static double Round(this double value, double nearest) return System.Math.Round(value / nearest) * nearest; } - /// - /// Saturates this double-precision floating-point number. - /// - /// The value to saturate. - /// The saturated value. - /// This method clamps between 0 and 1. - [Pure] - [MethodImpl(CompilerResources.MaxOptimization)] - public static double Saturate(this double value) - { - return System.Math.Clamp(value, 0.0, 1.0); - } - /// /// Returns the sine of the specified angle. /// diff --git a/X10D/src/Math/NumberExtensions.cs b/X10D/src/Math/NumberExtensions.cs index 6f14fdc24..3fdcc7ca3 100644 --- a/X10D/src/Math/NumberExtensions.cs +++ b/X10D/src/Math/NumberExtensions.cs @@ -113,6 +113,22 @@ public static TNumber Mod(this TNumber dividend, TNumber divisor) return r < TNumber.Zero ? r + divisor : r; } + /// + /// Saturates this number. + /// + /// The value to saturate. + /// The saturated value. + /// + /// This method clamps between and . + /// + [Pure] + [MethodImpl(CompilerResources.MaxOptimization)] + public static TNumber Saturate(this TNumber value) + where TNumber : INumber + { + return TNumber.Clamp(value, TNumber.Zero, TNumber.One); + } + /// /// Returns an integer that indicates the sign of this number. ///