Provides extended math primitives.
$ dotnet add package Gapotchenko.FX.MathThe module provides extended math primitives.
System.Math FunctionalitySystem.Math is a static class in the .NET Base Class Library (BCL) that provides commonly used mathematical operations. While comprehensive, its API leaves some practical gaps.
The Gapotchenko.FX.Math module complements System.Math class by extending its functionality to address those limitations.
The conventional System.Math class provides ubiquitous Min/Max primitives for two values.
However, such a limitation on number of values was proven counter-productive on more than several occasions.
Gapotchenko.FX.Math fixes that by providing Min/Max operations for three values:
using Gapotchenko.FX.Math;
using System;
Console.WriteLine(Math.Max(1, 2, 3));
Ever found yourself trying to find the maximum System.DateTime value? Or System.Version?
Gapotchenko.FX.Math module provides Min/Max operations for any comparable type:
using Gapotchenko.FX.Math;
using System;
var currentProgress = new DateTime(2012, 1, 1);
var desiredProgress = new DateTime(2026, 1, 1);
var fxProgress = Math.Max(currentProgress, desiredProgress);
Console.WriteLine(fxProgress);
MathExMathEx class provided by Gapotchenko.FX.Math module offers extended mathematical functions.
It is designed as a natural addendum to the standard System.Math class.
Some of the functionality provided by MathEx class is outlined below.
The MathEx.Factorial function computes the factorial of a given number:
using Gapotchenko.FX.Math;
Console.WriteLine(MathEx.Factorial(5));
Gapotchenko.FX.Math.MathExLet's continue with a look at some other modules provided by Gapotchenko.FX:
Or look at the full list of modules.