From 035c6cdd58fc17477a7f69779e26908c73a759b1 Mon Sep 17 00:00:00 2001 From: Michael Becker Date: Sun, 25 Jul 2021 09:14:16 -0400 Subject: [PATCH] implement ldexp function for convenience --- MBS.Framework/MBS.Framework.csproj | 1 + MBS.Framework/MathExtensions.cs | 27 +++++++++++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 MBS.Framework/MathExtensions.cs diff --git a/MBS.Framework/MBS.Framework.csproj b/MBS.Framework/MBS.Framework.csproj index 3497cc8..0afa25e 100644 --- a/MBS.Framework/MBS.Framework.csproj +++ b/MBS.Framework/MBS.Framework.csproj @@ -120,6 +120,7 @@ + diff --git a/MBS.Framework/MathExtensions.cs b/MBS.Framework/MathExtensions.cs new file mode 100644 index 0000000..e511af5 --- /dev/null +++ b/MBS.Framework/MathExtensions.cs @@ -0,0 +1,27 @@ +using System; +namespace MBS.Framework +{ + public static class MathExtensions + { + /// + /// Multiplies a floating point value x by the number 2 raised to the exp power. + /// + /// The ldexp. + /// The x coordinate. + /// Exp. + public static float ldexp(float x, int exp) + { + return (float)(x * Math.Pow(2, exp)); + } + /// + /// Multiplies a floating point value x by the number 2 raised to the exp power. + /// + /// The ldexp. + /// The x coordinate. + /// Exp. + public static double ldexp(double x, int exp) + { + return (x * Math.Pow(2, exp)); + } + } +}