📄 cmathf
字号:
/****************************************************************************/
/* cmathf v2.54 */
/* Copyright (c) 1999-2004 Texas Instruments Incorporated */
/****************************************************************************/
#ifndef __cmathf__
#define __cmathf__
#ifndef EDOM
#define EDOM 1
#endif
#ifndef ERANGE
#define ERANGE 2
#endif
#include <float.h>
#if (FLT_DIG == DBL_DIG) /* float is not different than double */
#include <cmath>
#define sqrtf sqrt
#define expf exp
#define logf log
#define log10f log10
#define powf pow
#define sinf sin
#define cosf cos
#define tanf tan
#define asinf asin
#define acosf acos
#define atanf atan
#define atan2f atan2
#define sinhf sinh
#define coshf cosh
#define tanhf tanh
#define ceilf ceil
#define floorf floor
#define fabsf fabs
#define ldexpf ldexp
#define frexpf frexp
#define modff modf
#define fmodf fmod
#ifdef _TI_ENHANCED_MATH_H
#define HUGE_VALF FLT_MAX
#define rsqrtf rsqrt
#define exp2f exp2
#define exp10f exp10
#define log2f log2
#define powif powi
#define cotf cot
#define acotf acot
#define acot2f acot2
#define cothf coth
#define asinhf asinh
#define acoshf acosh
#define atanhf atanh
#define acothf acoth
#define truncf _trunc
#define roundf _nround
#endif
#else /* float is different than double */
#include <access.h>
extern "C" namespace std
{
__EXTERN float sqrtf (float x);
__EXTERN float expf (float x);
__EXTERN float logf (float x);
__EXTERN float log10f(float x);
__EXTERN float powf (float x, float y);
__EXTERN float sinf (float x);
__EXTERN float cosf (float x);
__EXTERN float tanf (float x);
__EXTERN float asinf (float x);
__EXTERN float acosf (float x);
__EXTERN float atanf (float x);
__EXTERN float atan2f(float y, float x);
__EXTERN float sinhf (float x);
__EXTERN float coshf (float x);
__EXTERN float tanhf (float x);
__INLINE float ceilf (float x);
__INLINE float floorf(float x);
__EXTERN float fabsf (float x);
__EXTERN float ldexpf(float x, int n);
__EXTERN float frexpf(float x, int *exp);
__EXTERN float modff (float x, float *ip);
__EXTERN float fmodf (float x, float y);
/* An inline version of fmodf that works for limited domain only */
/* See comments in implementation below */
static inline float _FMODF(float x, float y);
/* these present in many linked images, so we'll tell you about them. */
__EXTERN float _roundf(float x); /* round-to-nearest */
__EXTERN float _truncf(float x); /* truncate towards 0 */
}
#ifdef _TI_ENHANCED_MATH_H
#if 0
/* ------------------------------------------------- */
/* Routines below are an addition to ANSI math.h */
/* Some (noted with "9x" in comment) will become ANSI*/
/* once C9x is approved. */
/* ------------------------------------------------- */
#endif
#define HUGE_VALF FLT_MAX /* 9x */
extern "C" namespace std
{
__EXTERN float rsqrtf(float x); /* == 1/sqrtf(x) but *MUCH* faster */
__EXTERN float exp2f (float x); /*9x mathematically equiv to powf(2.0 ,x) */
__EXTERN float exp10f(float x); /* mathematically equiv to powf(10.0,x) */
__EXTERN float log2f (float x); /*9x mathematically equiv to logf(x)/logf(2.)*/
__EXTERN float powif (float x, int i); /* equiv to powf(x,(float)i) */
__EXTERN float cotf (float x);
__EXTERN float acotf (float x);
__EXTERN float acot2f(float x, float y);
__EXTERN float cothf (float x);
__EXTERN float asinhf(float x); /* 9x */
__EXTERN float acoshf(float x); /* 9x */
__EXTERN float atanhf(float x); /* 9x */
__EXTERN float acothf(float x);
#define roundf(x) _roundf(x) /* 9x round-to-nearest */
#define truncf(x) _truncf(x) /* 9x truncate towards 0 */
} /* namespace */
#endif
#ifdef _INLINE
/****************************************************************************/
/* Inline versions of floorf, ceilf, fmodf */
/****************************************************************************/
static inline float std::floorf(float x)
{
float y;
return (std::modff(x, &y) < 0 ? y - 1 : y);
}
static inline float std::ceilf(float x)
{
float y;
return (std::modff(x, &y) > 0 ? y + 1 : y);
}
/*
The implementation below does not work correctly for all cases.
Consider the case of fmod(Big, 3), for any Big > 2**(MANT_DIG+2).
The correct result is one of 0,1, or 2.
But the implementation below will *always* return 0
because the quotient is only an approximation.
*/
static inline float _FMODF(float x, float y)
{
float d = std::fabsf(x);
if (d - std::fabsf(y) == d) return (0);
std::modff(x/y, &d);
return (x - d * y);
}
#endif
#include <unaccess.h>
#endif /* float is/isnot different than double */
#endif /* __cmathf__ */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -