X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=libs%2Fpbd%2Fmsvc%2Fmsvc_pbd.cc;h=ab79d8f45de8950213ef467112d5e8879c34a600;hb=a7df009de73ad38026ff97d9aeafb8e2aa22e627;hp=5b9c9d449af94bfc57eec0d2f0fcc7fe6a595a39;hpb=23e7cf10191270d70357ccf0ed9294f020c7b7ab;p=ardour.git diff --git a/libs/pbd/msvc/msvc_pbd.cc b/libs/pbd/msvc/msvc_pbd.cc index 5b9c9d449a..ab79d8f45d 100644 --- a/libs/pbd/msvc/msvc_pbd.cc +++ b/libs/pbd/msvc/msvc_pbd.cc @@ -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 { //***************************************************************