summaryrefslogtreecommitdiff
path: root/libs/pbd/msvc
diff options
context:
space:
mode:
authorJohn Emmas <johne53@tiscali.co.uk>2016-05-28 19:07:22 +0100
committerJohn Emmas <johne53@tiscali.co.uk>2016-05-28 19:07:22 +0100
commit22e031135ac2b81d8ac5d8d17d5a5a5b40281b6d (patch)
tree0ba1a82e4e1d008fb53b52287c51461c656d611d /libs/pbd/msvc
parentebeffdd2949b8d915c2bb8cc447a675d7a0de5da (diff)
Emulate 'log1p()' and 'expm1()' using 'log()' and 'exp()'
(for MSVC which didn't implement those functions until very recent versions).
Diffstat (limited to 'libs/pbd/msvc')
-rw-r--r--libs/pbd/msvc/msvc_pbd.cc42
1 files changed, 42 insertions, 0 deletions
diff --git a/libs/pbd/msvc/msvc_pbd.cc b/libs/pbd/msvc/msvc_pbd.cc
index ab79d8f45d..f49ac5393c 100644
--- a/libs/pbd/msvc/msvc_pbd.cc
+++ b/libs/pbd/msvc/msvc_pbd.cc
@@ -262,6 +262,47 @@ trunc(double x)
return (floor(x));
}
+#if defined(_MSC_VER) && (_MSC_VER < 1800)
+//***************************************************************
+//
+// expm1()
+//
+// Emulates C99 expm1() using exp().
+//
+// Returns:
+//
+// On Success: (('e' raised to the power of 'x') - 1)
+// (e.g. expm1(1) == 1.7182818).
+// On Failure: None, except that calling exp(x) should generate
+// an appropriate error for us (such as INF etc).
+//
+LIBPBD_API double PBD_APICALLTYPE
+expm1(double x)
+{
+ return (exp(x) - (double)1.0);
+}
+
+//***************************************************************
+//
+// log1p()
+//
+// Emulates C99 log1p() using log().
+//
+// Returns:
+//
+// On Success: The natural logarithm of (1 + x)
+// (e.g. log1p(1) == 0.69314718).
+// On Failure: None, except that calling log(x) should generate
+// an appropriate error for us (such as ERANGE etc).
+//
+LIBPBD_API double PBD_APICALLTYPE
+log1p(double x)
+{
+ return (log(x + (double)1.0));
+}
+#endif
+
+#if defined(_MSC_VER) && (_MSC_VER < 1900)
//***************************************************************
//
// log2()
@@ -280,6 +321,7 @@ log2(double x)
{
return (log(x) / log((double)2.0));
}
+#endif
namespace PBD {