feat: added basic math operations as Math methods
This commit is contained in:
@@ -5,6 +5,21 @@ namespace Syntriax.Engine.Core;
|
||||
|
||||
public static class MathExtensions
|
||||
{
|
||||
/// <inheritdoc cref="Math.Add{T}(T, T)" />
|
||||
public static T Add<T>(this T left, T value) where T : INumber<T> => Math.Add(left, value);
|
||||
|
||||
/// <inheritdoc cref="Math.Subtract{T}(T, T)" />
|
||||
public static T Subtract<T>(this T left, T value) where T : INumber<T> => Math.Subtract(left, value);
|
||||
|
||||
/// <inheritdoc cref="Math.Multiply{T}(T, T)" />
|
||||
public static T Multiply<T>(this T left, T multiplier) where T : INumber<T> => Math.Multiply(left, multiplier);
|
||||
|
||||
/// <inheritdoc cref="Math.Divide{T}(T, T)" />
|
||||
public static T Divide<T>(this T left, T divider) where T : INumber<T> => Math.Divide(left, divider);
|
||||
|
||||
/// <inheritdoc cref="Math.Mod{T}(T, T)" />
|
||||
public static T Mod<T>(this T value, T modulus) where T : INumber<T> => Math.Mod(value, modulus);
|
||||
|
||||
/// <inheritdoc cref="Math.Abs{T}(T)" />
|
||||
public static T Abs<T>(this T x) where T : INumber<T> => Math.Abs(x);
|
||||
|
||||
@@ -65,6 +80,9 @@ public static class MathExtensions
|
||||
/// <inheritdoc cref="Math.Round(float, int, MidpointRounding)" />
|
||||
public static float Round(this float x, int digits, MidpointRounding mode) => Math.Round(x, digits, mode);
|
||||
|
||||
/// <inheritdoc cref="Math.RoundToInt(float)" />
|
||||
public static int RoundToInt(this float x) => Math.RoundToInt(x);
|
||||
|
||||
/// <inheritdoc cref="Math.Sqr{T}(T)" />
|
||||
public static T Sqr<T>(this T x) where T : INumber<T> => Math.Sqr(x);
|
||||
|
||||
|
Reference in New Issue
Block a user