Tempo ramps - avoid sending negative beats to the BFC.
[ardour.git] / libs / pbd / msvc / msvc_pbd.cc
index 5b9c9d449af94bfc57eec0d2f0fcc7fe6a595a39..ab79d8f45de8950213ef467112d5e8879c34a600 100644 (file)
@@ -241,6 +241,46 @@ round(double x)
        return (floor(x));
 }
 
+//***************************************************************
+//
+//     trunc()
+//
+// Emulates trunc() using floor() and ceil().
+//
+//     Returns:
+//
+//    On Success: The largest integer whose magnitude is less
+//                than or equal to 'x' (regardless of sign).
+//    On Failure: None
+//
+LIBPBD_API double PBD_APICALLTYPE
+trunc(double x)
+{
+       if (x < 0)
+               return (ceil(x));
+
+       return (floor(x));
+}
+
+//***************************************************************
+//
+//     log2()
+//
+// Emulates C99 log2() using log().
+//
+//     Returns:
+//
+//    On Success: The binary (base-2) logarithm of 'x'
+//                (e.g. log2(1024) == 10).
+//    On Failure: None, except that calling log(x) should generate
+//                an appropriate error for us (such as ERANGE etc).
+//
+LIBPBD_API double PBD_APICALLTYPE
+log2(double x)
+{
+       return (log(x) / log((double)2.0));
+}
+
 namespace PBD {
 
 //***************************************************************