
Security News
ECMAScript 2025 Finalized with Iterator Helpers, Set Methods, RegExp.escape, and More
ECMAScript 2025 introduces Iterator Helpers, Set methods, JSON modules, and more in its latest spec update approved by Ecma in June 2025.
The module provides extended math primitives.
MathEx
is a class provided by Gapotchenko.FX.Math
module.
It offers extended mathematical functions,
and serves as an addendum to a conventional System.Math
class.
Some functions provided by MathEx
class are described below.
The swap operation is a widely demanded primitive:
Swap<T>(ref T val1, ref T val2)
Despite a trivial implementation, swap operation was found highly desirable during real-life coding sessions.
Swap
primitive allows to keep a mind of developer more focused on important things,
instead of writing tedious code like:
T temp = val1;
val1 = val2;
val2 = temp;
For comparison, please take a look at a concise version of the same:
MathEx.Swap(ref val1, ref val2);
The expression above gives an immediate improvement in readability.
Note that some .NET languages have a built-in support for swap operation.
For example, a modern C# code can swap val1
and val2
values using tuples, which is a highly recommended approach:
(val1, val2) = (val2, val1);
The conventional 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.
MathEx
fixes that by providing Min
/Max
operations for three values:
using Gapotchenko.FX.Math;
Console.WriteLine(MathEx.Max(1, 2, 3));
Ever found yourself trying to find the maximum System.DateTime
value? Or System.Version
?
MathEx
provides Min
/Max
operations for any comparable type:
using Gapotchenko.FX.Math;
var currentProgress = new DateTime(2012, 1, 1);
var desiredProgress = new DateTime(2025, 1, 1);
var fxProgress = MathEx.Max(currentProgress, desiredProgress);
Console.WriteLine(fxProgress);
Gapotchenko.FX.Math.MathEx
Let's continue with a look at some other modules provided by Gapotchenko.FX:
Or look at the full list of modules.
FAQs
Provides extended math primitives.
We found that gapotchenko.fx.math demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
ECMAScript 2025 introduces Iterator Helpers, Set methods, JSON modules, and more in its latest spec update approved by Ecma in June 2025.
Security News
A new Node.js homepage button linking to paid support for EOL versions has sparked a heated discussion among contributors and the wider community.
Research
North Korean threat actors linked to the Contagious Interview campaign return with 35 new malicious npm packages using a stealthy multi-stage malware loader.