implement ldexp function for convenience

This commit is contained in:
Michael Becker 2021-07-25 09:14:16 -04:00
parent 95495ac334
commit 035c6cdd58
No known key found for this signature in database
GPG Key ID: 98C333A81F18C22C
2 changed files with 28 additions and 0 deletions

View File

@ -120,6 +120,7 @@
<Compile Include="UserInterface\VerticalAlignment.cs" /> <Compile Include="UserInterface\VerticalAlignment.cs" />
<Compile Include="CustomSettingsProvider.cs" /> <Compile Include="CustomSettingsProvider.cs" />
<Compile Include="Settings\VersionSetting.cs" /> <Compile Include="Settings\VersionSetting.cs" />
<Compile Include="MathExtensions.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Folder Include="Logic\" /> <Folder Include="Logic\" />

View File

@ -0,0 +1,27 @@
using System;
namespace MBS.Framework
{
public static class MathExtensions
{
/// <summary>
/// Multiplies a floating point value x by the number 2 raised to the exp power.
/// </summary>
/// <returns>The ldexp.</returns>
/// <param name="x">The x coordinate.</param>
/// <param name="exp">Exp.</param>
public static float ldexp(float x, int exp)
{
return (float)(x * Math.Pow(2, exp));
}
/// <summary>
/// Multiplies a floating point value x by the number 2 raised to the exp power.
/// </summary>
/// <returns>The ldexp.</returns>
/// <param name="x">The x coordinate.</param>
/// <param name="exp">Exp.</param>
public static double ldexp(double x, int exp)
{
return (x * Math.Pow(2, exp));
}
}
}