13
0

Emulate exp2f() for older MS compilers where it wasn't available

This commit is contained in:
John Emmas 2021-05-05 17:50:41 +01:00
parent 5957e14259
commit a222292e68
3 changed files with 22 additions and 2 deletions

View File

@ -242,6 +242,24 @@ expm1(double x)
return (exp(x) - (double)1.0); return (exp(x) - (double)1.0);
} }
//***************************************************************
//
// exp2f()
//
// Emulates C99 exp2f() using powf().
//
// Returns:
//
// On Success: 2 raised to the power of 'x'
// On Failure: None, except that calling powf(x) should generate
// an appropriate error for us (such as INF etc).
//
LIBPBD_API float PBD_APICALLTYPE
exp2f(float x)
{
return (powf(2.0f, x));
}
//*************************************************************** //***************************************************************
// //
// log1p() // log1p()

View File

@ -172,9 +172,10 @@ LIBPBD_API ssize_t PBD_APICALLTYPE pread(int handle, void *buf, size_t nbytes,
LIBPBD_API ssize_t PBD_APICALLTYPE pwrite(int handle, const void *buf, size_t nbytes, off_t offset); LIBPBD_API ssize_t PBD_APICALLTYPE pwrite(int handle, const void *buf, size_t nbytes, off_t offset);
#if defined(_MSC_VER) && (_MSC_VER < 1800) #if defined(_MSC_VER) && (_MSC_VER < 1800)
LIBPBD_API double PBD_APICALLTYPE expm1(double x);
LIBPBD_API double PBD_APICALLTYPE log1p(double x); LIBPBD_API double PBD_APICALLTYPE log1p(double x);
LIBPBD_API double PBD_APICALLTYPE round(double x); LIBPBD_API double PBD_APICALLTYPE round(double x);
LIBPBD_API double PBD_APICALLTYPE expm1(double x);
LIBPBD_API float PBD_APICALLTYPE exp2f(float x);
LIBPBD_API float PBD_APICALLTYPE roundf(float x); LIBPBD_API float PBD_APICALLTYPE roundf(float x);
#endif #endif

View File

@ -272,9 +272,10 @@ inline int64_t abs(int64_t val) throw()
// Emulate some C99 math functions which MSVC itself didn't // Emulate some C99 math functions which MSVC itself didn't
// implement until later in life. // implement until later in life.
#if defined(_MSC_VER) && (_MSC_VER < 1800) #if defined(_MSC_VER) && (_MSC_VER < 1800)
extern double expm1(double x);
extern double log1p(double x); extern double log1p(double x);
extern double round(double x); extern double round(double x);
extern double expm1(double x);
extern float exp2f(float x);
extern float roundf(float x); extern float roundf(float x);
#endif #endif
#if defined(_MSC_VER) && (_MSC_VER < 1900) #if defined(_MSC_VER) && (_MSC_VER < 1900)