Extends the System.Math class, but uses floats and provides some extra constants.
View code on GitHub System Object DeltaEngine.Extensions MathExtensionsNamespace: DeltaEngine.ExtensionsAssembly: DeltaEngine (in DeltaEngine.dll) Version: 1.1.1.0 (1.1.1)
public static class MathExtensions
public static class MathExtensions
<ExtensionAttribute>
Public NotInheritable Class MathExtensions
<ExtensionAttribute>
Public NotInheritable Class MathExtensions
[ExtensionAttribute]
public ref class MathExtensions abstract sealed
[ExtensionAttribute]
public ref class MathExtensions abstract sealed
[<AbstractClassAttribute>]
[<SealedAttribute>]
type MathExtensions = class end
[<AbstractClassAttribute>]
[<SealedAttribute>]
type MathExtensions = class end
The MathExtensions type exposes the following members.
TopTopTests:
DeltaEngine.Tests.Extensions.MathExtensionsTests19 unit tests call DeltaEngine.Extensions.MathExtensions
[Test]
public void Abs()
{
Assert.AreEqual(5, MathExtensions.Abs(2) + MathExtensions.Abs(3));
Assert.AreEqual(5, MathExtensions.Abs(-2) + MathExtensions.Abs(3));
Assert.AreEqual(5, 2.0f.Abs() + 3.0f.Abs());
Assert.AreEqual(5, (-2.0f).Abs() + 3.0f.Abs());
}
[Test]
public void Abs()
{
Assert.AreEqual(5, MathExtensions.Abs(2) + MathExtensions.Abs(3));
Assert.AreEqual(5, MathExtensions.Abs(-2) + MathExtensions.Abs(3));
Assert.AreEqual(5, 2.0f.Abs() + 3.0f.Abs());
Assert.AreEqual(5, (-2.0f).Abs() + 3.0f.Abs());
}
[Test]
public void IsNearlyEqual()
{
Assert.IsTrue(2.0f.IsNearlyEqual(2.00001f));
Assert.IsFalse(2.0f.IsNearlyEqual(2.0002f));
Assert.IsTrue(MathExtensions.Pi.IsNearlyEqual(3.1415f));
}
[Test]
public void IsNearlyEqual()
{
Assert.IsTrue(2.0f.IsNearlyEqual(2.00001f));
Assert.IsFalse(2.0f.IsNearlyEqual(2.0002f));
Assert.IsTrue(MathExtensions.Pi.IsNearlyEqual(3.1415f));
}
[Test]
public static void Round()
{
Assert.AreEqual(1, 1.25f.Round());
Assert.AreEqual(10, 9.68f.Round());
Assert.AreEqual(1.23f, 1.2345f.Round(2));
}
[Test]
public static void Round()
{
Assert.AreEqual(1, 1.25f.Round());
Assert.AreEqual(10, 9.68f.Round());
Assert.AreEqual(1.23f, 1.2345f.Round(2));
}