ReactOS 0.4.16-dev-2204-g370eb8c
math.h File Reference
#include <corecrt.h>
#include <pshpack8.h>
#include <poppack.h>
Include dependency graph for math.h:

Go to the source code of this file.

Classes

struct  _exception
 
struct  _complex
 

Macros

#define _DOMAIN   1 /* domain error in argument */
 
#define _SING   2 /* singularity */
 
#define _OVERFLOW   3 /* range overflow */
 
#define _UNDERFLOW   4 /* range underflow */
 
#define _TLOSS   5 /* total loss of precision */
 
#define _PLOSS   6 /* partial loss of precision */
 
#define _EXCEPTION_DEFINED
 
#define _COMPLEX_DEFINED
 
#define copysign(x, y)   _copysign(x,y)
 
#define copysignf(x, y)   _copysignf(x,y)
 
#define INFINITY   (__inff.__f)
 
#define NAN   (__nanf.__f)
 
#define HUGE_VAL   ((double)INFINITY)
 
#define FP_INFINITE   1
 
#define FP_NAN   2
 
#define FP_NORMAL   -1
 
#define FP_SUBNORMAL   -2
 
#define FP_ZERO   0
 
#define _C2   1
 
#define FP_ILOGB0   (-0x7fffffff - _C2)
 
#define FP_ILOGBNAN   0x7fffffff
 
#define isinf(x)   (sizeof(x) == sizeof(float) ? __isinff(x) : __isinf(x))
 
#define isnan(x)   (sizeof(x) == sizeof(float) ? __isnanf(x) : __isnan(x))
 
#define isnormal(x)   (sizeof(x) == sizeof(float) ? __isnormalf(x) : __isnormal(x))
 
#define signbit(x)   (sizeof(x) == sizeof(float) ? __signbitf(x) : __signbit(x))
 
#define isfinite(x)   (!isinf(x) && !isnan(x))
 
#define _MATH_DEFINES_DEFINED
 
#define M_E   2.71828182845904523536
 
#define M_LOG2E   1.44269504088896340736
 
#define M_LOG10E   0.434294481903251827651
 
#define M_LN2   0.693147180559945309417
 
#define M_LN10   2.30258509299404568402
 
#define M_PI   3.14159265358979323846
 
#define M_PI_2   1.57079632679489661923
 
#define M_PI_4   0.785398163397448309616
 
#define M_1_PI   0.318309886183790671538
 
#define M_2_PI   0.636619772367581343076
 
#define M_2_SQRTPI   1.12837916709551257390
 
#define M_SQRT2   1.41421356237309504880
 
#define M_SQRT1_2   0.707106781186547524401
 

Functions

_ACRTIMP double __cdecl sin (double)
 
_ACRTIMP double __cdecl cos (double)
 
_ACRTIMP double __cdecl tan (double)
 
_ACRTIMP double __cdecl sinh (double)
 
_ACRTIMP double __cdecl cosh (double)
 
_ACRTIMP double __cdecl tanh (double)
 
_ACRTIMP double __cdecl asin (double)
 
_ACRTIMP double __cdecl acos (double)
 
_ACRTIMP double __cdecl atan (double)
 
_ACRTIMP double __cdecl atan2 (double, double)
 
_ACRTIMP double __cdecl asinh (double)
 
_ACRTIMP double __cdecl acosh (double)
 
_ACRTIMP double __cdecl atanh (double)
 
_ACRTIMP double __cdecl exp (double)
 
_ACRTIMP double __cdecl log (double)
 
_ACRTIMP double __cdecl log10 (double)
 
_ACRTIMP double __cdecl pow (double, double)
 
_ACRTIMP double __cdecl sqrt (double)
 
_ACRTIMP double __cdecl ceil (double)
 
_ACRTIMP double __cdecl floor (double)
 
_ACRTIMP double __cdecl fabs (double)
 
_ACRTIMP double __cdecl ldexp (double, int)
 
_ACRTIMP double __cdecl frexp (double, int *)
 
_ACRTIMP double __cdecl modf (double, double *)
 
_ACRTIMP double __cdecl fdim (double, double)
 
_ACRTIMP double __cdecl fmod (double, double)
 
_ACRTIMP double __cdecl fmin (double, double)
 
_ACRTIMP double __cdecl fmax (double, double)
 
_ACRTIMP double __cdecl erf (double)
 
_ACRTIMP double __cdecl remainder (double, double)
 
_ACRTIMP double __cdecl remquo (double, double, int *)
 
_ACRTIMP float __cdecl remquof (float, float, int *)
 
_ACRTIMP double __cdecl lgamma (double)
 
_ACRTIMP double __cdecl tgamma (double)
 
_ACRTIMP double __cdecl _hypot (double, double)
 
_ACRTIMP double __cdecl _j0 (double)
 
_ACRTIMP double __cdecl _j1 (double)
 
_ACRTIMP double __cdecl _jn (int, double)
 
_ACRTIMP double __cdecl _y0 (double)
 
_ACRTIMP double __cdecl _y1 (double)
 
_ACRTIMP double __cdecl _yn (int, double)
 
_ACRTIMP double __cdecl cbrt (double)
 
_ACRTIMP double __cdecl exp2 (double)
 
_ACRTIMP double __cdecl expm1 (double)
 
_ACRTIMP double __cdecl log1p (double)
 
_ACRTIMP double __cdecl log2 (double)
 
_ACRTIMP double __cdecl logb (double)
 
_ACRTIMP double __cdecl rint (double)
 
_ACRTIMP double __cdecl round (double)
 
_ACRTIMP double __cdecl trunc (double)
 
_ACRTIMP float __cdecl cbrtf (float)
 
_ACRTIMP float __cdecl exp2f (float)
 
_ACRTIMP float __cdecl expm1f (float)
 
_ACRTIMP float __cdecl log1pf (float)
 
_ACRTIMP float __cdecl log2f (float)
 
_ACRTIMP float __cdecl logbf (float)
 
_ACRTIMP float __cdecl rintf (float)
 
_ACRTIMP float __cdecl roundf (float)
 
_ACRTIMP float __cdecl truncf (float)
 
_ACRTIMP int __cdecl ilogb (double)
 
_ACRTIMP int __cdecl ilogbf (float)
 
_ACRTIMP float __cdecl fmaf (float x, float y, float z)
 
_ACRTIMP double __cdecl fma (double x, double y, double z)
 
_ACRTIMP __int64 __cdecl llrint (double)
 
_ACRTIMP __int64 __cdecl llrintf (float)
 
_ACRTIMP __int64 __cdecl llround (double)
 
_ACRTIMP __int64 __cdecl llroundf (float)
 
_ACRTIMP __msvcrt_long __cdecl lrint (double)
 
_ACRTIMP __msvcrt_long __cdecl lrintf (float)
 
_ACRTIMP __msvcrt_long __cdecl lround (double)
 
_ACRTIMP __msvcrt_long __cdecl lroundf (float)
 
_ACRTIMP double __cdecl scalbn (double, int)
 
_ACRTIMP float __cdecl scalbnf (float, int)
 
_ACRTIMP double __cdecl scalbln (double, __msvcrt_long)
 
_ACRTIMP float __cdecl scalblnf (float, __msvcrt_long)
 
_ACRTIMP double __cdecl _copysign (double, double)
 
_ACRTIMP double __cdecl _chgsign (double)
 
_ACRTIMP double __cdecl _scalb (double, __msvcrt_long)
 
_ACRTIMP double __cdecl _logb (double)
 
_ACRTIMP double __cdecl _nextafter (double, double)
 
_ACRTIMP int __cdecl _finite (double)
 
_ACRTIMP int __cdecl _isnan (double)
 
_ACRTIMP int __cdecl _fpclass (double)
 
_ACRTIMP double __cdecl nextafter (double, double)
 
_ACRTIMP float __cdecl sinf (float)
 
_ACRTIMP float __cdecl cosf (float)
 
_ACRTIMP float __cdecl tanf (float)
 
_ACRTIMP float __cdecl sinhf (float)
 
_ACRTIMP float __cdecl coshf (float)
 
_ACRTIMP float __cdecl tanhf (float)
 
_ACRTIMP float __cdecl asinf (float)
 
_ACRTIMP float __cdecl acosf (float)
 
_ACRTIMP float __cdecl atanf (float)
 
_ACRTIMP float __cdecl atan2f (float, float)
 
_ACRTIMP float __cdecl atanhf (float)
 
_ACRTIMP float __cdecl expf (float)
 
_ACRTIMP float __cdecl logf (float)
 
_ACRTIMP float __cdecl log10f (float)
 
_ACRTIMP float __cdecl powf (float, float)
 
_ACRTIMP float __cdecl sqrtf (float)
 
_ACRTIMP float __cdecl ceilf (float)
 
_ACRTIMP float __cdecl floorf (float)
 
_ACRTIMP float __cdecl modff (float, float *)
 
_ACRTIMP float __cdecl fmodf (float, float)
 
_ACRTIMP int __cdecl _finitef (float)
 
_ACRTIMP int __cdecl _isnanf (float)
 
_ACRTIMP int __cdecl _fpclassf (float)
 
static float frexpf (float x, int *y)
 
_ACRTIMP float __cdecl fabsf (float)
 
_ACRTIMP float __cdecl _chgsignf (float)
 
_ACRTIMP float __cdecl _copysignf (float, float)
 
_ACRTIMP float __cdecl _logbf (float)
 
_ACRTIMP float __cdecl acoshf (float)
 
_ACRTIMP float __cdecl asinhf (float)
 
_ACRTIMP float __cdecl erff (float)
 
_ACRTIMP float __cdecl fdimf (float, float)
 
_ACRTIMP float __cdecl fmaxf (float, float)
 
_ACRTIMP float __cdecl fminf (float, float)
 
_ACRTIMP float __cdecl lgammaf (float)
 
_ACRTIMP float __cdecl nextafterf (float, float)
 
_ACRTIMP float __cdecl remainderf (float, float)
 
_ACRTIMP float __cdecl tgammaf (float)
 
static float ldexpf (float x, int y)
 
_ACRTIMP double __cdecl nearbyint (double)
 
_ACRTIMP float __cdecl nearbyintf (float)
 
_ACRTIMP float __cdecl _hypotf (float, float)
 
_ACRTIMP int __cdecl _matherr (struct _exception *)
 
_ACRTIMP double __cdecl _cabs (struct _complex)
 
_ACRTIMP short __cdecl _dtest (double *)
 
_ACRTIMP short __cdecl _ldtest (long double *)
 
_ACRTIMP short __cdecl _fdtest (float *)
 
static int __isnanf (float x)
 
static int __isnan (double x)
 
static int __isinff (float x)
 
static int __isinf (double x)
 
static int __isnormalf (float x)
 
static int __isnormal (double x)
 
static int __signbitf (float x)
 
static int __signbit (double x)
 
static double hypot (double x, double y)
 
static double j0 (double x)
 
static double j1 (double x)
 
static double jn (int n, double x)
 
static double y0 (double x)
 
static double y1 (double x)
 
static double yn (int n, double x)
 
static float hypotf (float x, float y)
 
static long double atan2l (long double x, long double y)
 

Variables

union {
   unsigned int   __i
 
   float   __f
 
__inff = { 0x7f800000 }
 
union {
   unsigned int   __i
 
   float   __f
 
__nanf = { 0x7fc00000 }
 

Macro Definition Documentation

◆ _C2

#define _C2   1

Definition at line 283 of file math.h.

◆ _COMPLEX_DEFINED

#define _COMPLEX_DEFINED

Definition at line 40 of file math.h.

◆ _DOMAIN

#define _DOMAIN   1 /* domain error in argument */

Definition at line 20 of file math.h.

◆ _EXCEPTION_DEFINED

#define _EXCEPTION_DEFINED

Definition at line 28 of file math.h.

◆ _MATH_DEFINES_DEFINED

#define _MATH_DEFINES_DEFINED

Definition at line 403 of file math.h.

◆ _OVERFLOW

#define _OVERFLOW   3 /* range overflow */

Definition at line 22 of file math.h.

◆ _PLOSS

#define _PLOSS   6 /* partial loss of precision */

Definition at line 25 of file math.h.

◆ _SING

#define _SING   2 /* singularity */

Definition at line 21 of file math.h.

◆ _TLOSS

#define _TLOSS   5 /* total loss of precision */

Definition at line 24 of file math.h.

◆ _UNDERFLOW

#define _UNDERFLOW   4 /* range underflow */

Definition at line 23 of file math.h.

◆ copysign

#define copysign (   x,
  y 
)    _copysign(x,y)

Definition at line 253 of file math.h.

◆ copysignf

#define copysignf (   x,
  y 
)    _copysignf(x,y)

Definition at line 254 of file math.h.

◆ FP_ILOGB0

#define FP_ILOGB0   (-0x7fffffff - _C2)

Definition at line 284 of file math.h.

◆ FP_ILOGBNAN

#define FP_ILOGBNAN   0x7fffffff

Definition at line 285 of file math.h.

◆ FP_INFINITE

#define FP_INFINITE   1

Definition at line 277 of file math.h.

◆ FP_NAN

#define FP_NAN   2

Definition at line 278 of file math.h.

◆ FP_NORMAL

#define FP_NORMAL   -1

Definition at line 279 of file math.h.

◆ FP_SUBNORMAL

#define FP_SUBNORMAL   -2

Definition at line 280 of file math.h.

◆ FP_ZERO

#define FP_ZERO   0

Definition at line 281 of file math.h.

◆ HUGE_VAL

#define HUGE_VAL   ((double)INFINITY)

Definition at line 274 of file math.h.

◆ INFINITY

#define INFINITY   (__inff.__f)

Definition at line 272 of file math.h.

◆ isfinite

#define isfinite (   x)    (!isinf(x) && !isnan(x))

Definition at line 363 of file math.h.

◆ isinf

#define isinf (   x)    (sizeof(x) == sizeof(float) ? __isinff(x) : __isinf(x))

Definition at line 359 of file math.h.

◆ isnan

#define isnan (   x)    (sizeof(x) == sizeof(float) ? __isnanf(x) : __isnan(x))

Definition at line 360 of file math.h.

◆ isnormal

#define isnormal (   x)    (sizeof(x) == sizeof(float) ? __isnormalf(x) : __isnormal(x))

Definition at line 361 of file math.h.

◆ M_1_PI

#define M_1_PI   0.318309886183790671538

Definition at line 412 of file math.h.

◆ M_2_PI

#define M_2_PI   0.636619772367581343076

Definition at line 413 of file math.h.

◆ M_2_SQRTPI

#define M_2_SQRTPI   1.12837916709551257390

Definition at line 414 of file math.h.

◆ M_E

#define M_E   2.71828182845904523536

Definition at line 404 of file math.h.

◆ M_LN10

#define M_LN10   2.30258509299404568402

Definition at line 408 of file math.h.

◆ M_LN2

#define M_LN2   0.693147180559945309417

Definition at line 407 of file math.h.

◆ M_LOG10E

#define M_LOG10E   0.434294481903251827651

Definition at line 406 of file math.h.

◆ M_LOG2E

#define M_LOG2E   1.44269504088896340736

Definition at line 405 of file math.h.

◆ M_PI

#define M_PI   3.14159265358979323846

Definition at line 409 of file math.h.

◆ M_PI_2

#define M_PI_2   1.57079632679489661923

Definition at line 410 of file math.h.

◆ M_PI_4

#define M_PI_4   0.785398163397448309616

Definition at line 411 of file math.h.

◆ M_SQRT1_2

#define M_SQRT1_2   0.707106781186547524401

Definition at line 416 of file math.h.

◆ M_SQRT2

#define M_SQRT2   1.41421356237309504880

Definition at line 415 of file math.h.

◆ NAN

#define NAN   (__nanf.__f)

Definition at line 273 of file math.h.

◆ signbit

#define signbit (   x)    (sizeof(x) == sizeof(float) ? __signbitf(x) : __signbit(x))

Definition at line 362 of file math.h.

Function Documentation

◆ __isinf()

static int __isinf ( double  x)
inlinestatic

Definition at line 333 of file math.h.

334{
335 union { double x; unsigned __int64 i; } u = { x };
336 return (u.i & ~0ull >> 1) == 0x7ffull << 52;
337}
#define __int64
Definition: corecrt.h:72
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble * u
Definition: glfuncs.h:240

◆ __isinff()

static int __isinff ( float  x)
inlinestatic

Definition at line 328 of file math.h.

329{
330 union { float x; unsigned int i; } u = { x };
331 return (u.i & 0x7fffffff) == 0x7f800000;
332}

◆ __isnan()

static int __isnan ( double  x)
inlinestatic

Definition at line 323 of file math.h.

324{
325 union { double x; unsigned __int64 i; } u = { x };
326 return (u.i & ~0ull >> 1) > 0x7ffull << 52;
327}

◆ __isnanf()

static int __isnanf ( float  x)
inlinestatic

Definition at line 318 of file math.h.

319{
320 union { float x; unsigned int i; } u = { x };
321 return (u.i & 0x7fffffff) > 0x7f800000;
322}

◆ __isnormal()

static int __isnormal ( double  x)
inlinestatic

Definition at line 343 of file math.h.

344{
345 union { double x; unsigned __int64 i; } u = { x };
346 return ((u.i + (1ull << 52)) & ~0ull >> 1) >= 1ull << 53;
347}

◆ __isnormalf()

static int __isnormalf ( float  x)
inlinestatic

Definition at line 338 of file math.h.

339{
340 union { float x; unsigned int i; } u = { x };
341 return ((u.i + 0x00800000) & 0x7fffffff) >= 0x01000000;
342}

◆ __signbit()

static int __signbit ( double  x)
inlinestatic

Definition at line 353 of file math.h.

354{
355 union { double x; unsigned __int64 i; } u = { x };
356 return (int)(u.i >> 63);
357}

◆ __signbitf()

static int __signbitf ( float  x)
inlinestatic

Definition at line 348 of file math.h.

349{
350 union { float x; unsigned int i; } u = { x };
351 return (int)(u.i >> 31);
352}

◆ _cabs()

Definition at line 1219 of file math.c.

1220{
1221 return sqrt(num.x * num.x + num.y * num.y);
1222}
_ACRTIMP double __cdecl sqrt(double)
Definition: sqrt.c:5
GLuint GLuint num
Definition: glext.h:9618

◆ _chgsign()

_ACRTIMP double __cdecl _chgsign ( double  num)

Definition at line 1227 of file math.c.

1228{
1229 union { double f; UINT64 i; } u = { num };
1230 u.i ^= 1ull << 63;
1231 return u.f;
1232}
unsigned long long UINT64
#define f
Definition: ke_i.h:83

Referenced by _chgsignf(), and _chgsignl().

◆ _chgsignf()

_ACRTIMP float __cdecl _chgsignf ( float  num)

Definition at line 203 of file math.c.

204{
205 union { float f; UINT32 i; } u = { num };
206 u.i ^= 0x80000000;
207 return u.f;
208}
unsigned int UINT32

◆ _copysign()

_ACRTIMP double __cdecl _copysign ( double  __d,
double  __s 
)

Definition at line 17 of file copysign.c.

18{
19 union
20 {
21 double* __d;
22 double_s* d;
23 } d;
24 union
25 {
26 double* __s;
27 double_s* s;
28 } s;
29 d.__d = &__d;
30 s.__s = &__s;
31
32 d.d->sign = s.s->sign;
33
34 return __d;
35}
GLdouble s
Definition: gl.h:2039
#define d
Definition: ke_i.h:81
Definition: ieee.h:10

Referenced by _copysignf(), and _copysignl().

◆ _copysignf()

_ACRTIMP float __cdecl _copysignf ( float  x,
float  y 
)

Definition at line 34 of file _copysignf.c.

35{
36 unsigned int ux, uy;
37 GET_BITS_SP32(x, ux);
38 GET_BITS_SP32(y, uy);
39 if ((ux ^ uy) & SIGNBIT_SP32)
41 return x;
42}
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
#define GET_BITS_SP32(x, ux)
Definition: libm_util.h:105
#define SIGNBIT_SP32
Definition: libm_util.h:68
#define PUT_BITS_SP32(ux, x)
Definition: libm_util.h:111

◆ _dtest()

_ACRTIMP short __cdecl _dtest ( double )

◆ _fdtest()

_ACRTIMP short __cdecl _fdtest ( float )

◆ _finite()

_ACRTIMP int __cdecl _finite ( double  num)

Definition at line 1582 of file math.c.

1583{
1584 union { double f; UINT64 i; } u = { num };
1585 return (u.i & ~0ull >> 1) < 0x7ffull << 52;
1586}

◆ _finitef()

_ACRTIMP int __cdecl _finitef ( float  num)

Definition at line 239 of file math.c.

240{
241 union { float f; UINT32 i; } u = { num };
242 return (u.i & 0x7fffffff) < 0x7f800000;
243}

Referenced by Test__finitef().

◆ _fpclass()

_ACRTIMP int __cdecl _fpclass ( double  num)

Definition at line 595 of file math.c.

596{
597 union { double f; UINT64 i; } u = { num };
598 int e = u.i >> 52 & 0x7ff;
599 int s = u.i >> 63;
600
601 switch (e)
602 {
603 case 0:
604 if (u.i << 1) return s ? _FPCLASS_ND : _FPCLASS_PD;
605 return s ? _FPCLASS_NZ : _FPCLASS_PZ;
606 case 0x7ff:
607 if (u.i << 12) return ((u.i >> 51) & 1) ? _FPCLASS_QNAN : _FPCLASS_SNAN;
608 return s ? _FPCLASS_NINF : _FPCLASS_PINF;
609 default:
610 return s ? _FPCLASS_NN : _FPCLASS_PN;
611 }
612}
#define _FPCLASS_PZ
Definition: float.h:113
#define _FPCLASS_PD
Definition: float.h:114
#define _FPCLASS_PN
Definition: float.h:115
#define _FPCLASS_ND
Definition: float.h:111
#define _FPCLASS_QNAN
Definition: float.h:108
#define _FPCLASS_NINF
Definition: float.h:109
#define _FPCLASS_NN
Definition: float.h:110
#define _FPCLASS_SNAN
Definition: float.h:107
#define _FPCLASS_NZ
Definition: float.h:112
#define _FPCLASS_PINF
Definition: float.h:116
#define e
Definition: ke_i.h:82

◆ _fpclassf()

_ACRTIMP int __cdecl _fpclassf ( float  num)

Definition at line 217 of file math.c.

218{
219 union { float f; UINT32 i; } u = { num };
220 int e = u.i >> 23 & 0xff;
221 int s = u.i >> 31;
222
223 switch (e)
224 {
225 case 0:
226 if (u.i << 1) return s ? _FPCLASS_ND : _FPCLASS_PD;
227 return s ? _FPCLASS_NZ : _FPCLASS_PZ;
228 case 0xff:
229 if (u.i << 9) return ((u.i >> 22) & 1) ? _FPCLASS_QNAN : _FPCLASS_SNAN;
230 return s ? _FPCLASS_NINF : _FPCLASS_PINF;
231 default:
232 return s ? _FPCLASS_NN : _FPCLASS_PN;
233 }
234}

◆ _hypot()

_ACRTIMP double __cdecl _hypot ( double  x,
double  y 
)

Definition at line 34 of file hypot.c.

35{
36 double abig = fabs(x), asmall = fabs(y);
37 double ratio;
38
39 /* Make abig = max(|x|, |y|), asmall = min(|x|, |y|). */
40 if (abig < asmall)
41 {
42 double temp = abig;
43
44 abig = asmall;
45 asmall = temp;
46 }
47
48 /* Trivial case. */
49 if (asmall == 0.)
50 return abig;
51
52 /* Scale the numbers as much as possible by using its ratio.
53 For example, if both ABIG and ASMALL are VERY small, then
54 X^2 + Y^2 might be VERY inaccurate due to loss of
55 significant digits. Dividing ASMALL by ABIG scales them
56 to a certain degree, so that accuracy is better. */
57
58 if ((ratio = asmall / abig) > __SQRT_DBL_MIN && abig < __SQRT_DBL_MAX)
59 return abig * sqrt(1.0 + ratio*ratio);
60 else
61 {
62 /* Slower but safer algorithm due to Moler and Morrison. Never
63 produces any intermediate result greater than roughly the
64 larger of X and Y. Should converge to machine-precision
65 accuracy in 3 iterations. */
66
67 double r = ratio*ratio, t, s, p = abig, q = asmall;
68
69 do {
70 t = 4. + r;
71 if (t == 4.)
72 break;
73 s = r / t;
74 p += 2. * s * p;
75 q *= s;
76 r = (q / p) * (q / p);
77 } while (1);
78
79 return p;
80 }
81}
_ACRTIMP double __cdecl fabs(double)
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLdouble GLdouble t
Definition: gl.h:2047
GLdouble GLdouble GLdouble GLdouble q
Definition: gl.h:2063
GLfloat GLfloat p
Definition: glext.h:8902
#define __SQRT_DBL_MAX
Definition: hypot.c:27
#define __SQRT_DBL_MIN
Definition: hypot.c:28
static calc_node_t temp
Definition: rpn_ieee.c:38

Referenced by _cabs(), _hypotf(), _hypotl(), hypot(), and hypotl().

◆ _hypotf()

_ACRTIMP float __cdecl _hypotf ( float  x,
float  y 
)

Definition at line 45 of file hypotf.c.

46{
47 /* Returns sqrt(x*x + y*y) with no overflow or underflow unless
48 the result warrants it */
49
50 /* Do intermediate computations in double precision
51 and use sqrt instruction from chip if available. */
52 double dx = x, dy = y, dr, retval;
53
54 /* The largest finite float, stored as a double */
55 const double large = 3.40282346638528859812e+38; /* 0x47efffffe0000000 */
56
57
58 unsigned long long ux, uy, avx, avy;
59
61 avx &= ~SIGNBIT_DP64;
62 GET_BITS_DP64(y, avy);
63 avy &= ~SIGNBIT_DP64;
64 ux = (avx >> EXPSHIFTBITS_DP64);
65 uy = (avy >> EXPSHIFTBITS_DP64);
66
67 if (ux == BIASEDEMAX_DP64 + 1 || uy == BIASEDEMAX_DP64 + 1)
68 {
69 retval = x*x + y*y;
70 /* One or both of the arguments are NaN or infinity. The
71 result will also be NaN or infinity. */
72 if (((ux == BIASEDEMAX_DP64 + 1) && !(avx & MANTBITS_DP64)) ||
73 ((uy == BIASEDEMAX_DP64 + 1) && !(avy & MANTBITS_DP64)))
74 /* x or y is infinity. ISO C99 defines that we must
75 return +infinity, even if the other argument is NaN.
76 Note that the computation of x*x + y*y above will already
77 have raised invalid if either x or y is a signalling NaN. */
78 return infinityf_with_flags(0);
79 else
80 /* One or both of x or y is NaN, and neither is infinity.
81 Raise invalid if it's a signalling NaN */
82 return (float)retval;
83 }
84
85 dr = (dx*dx + dy*dy);
86
87#if USE_SOFTWARE_SQRT
88 retval = sqrtf_amd_inline(r);
89#else
90 /* VC++ intrinsic call */
92#endif
93
94 if (retval > large)
95 return _handle_errorf("_hypotf", OP_HYPOT, PINFBITPATT_SP32, _OVERFLOW,
97 else
98 return (float)retval;
99}
float __cdecl _handle_errorf(char *fname, int opcode, unsigned long long value, int type, int flags, int error, float arg1, float arg2, int nargs)
Definition: _handle_error.c:56
#define ERANGE
Definition: errno.h:55
#define _OVERFLOW
Definition: math.h:22
__m128d _mm_setzero_pd(void)
Definition: emmintrin.h:1057
__m128d _mm_sqrt_sd(__m128d a, __m128d b)
Definition: emmintrin.h:620
__m128d _mm_load_sd(double const *dp)
Definition: emmintrin.h:1000
void _mm_store_sd(double *dp, __m128d a)
Definition: emmintrin.h:1068
#define AMD_F_INEXACT
Definition: libm_new.h:82
#define AMD_F_OVERFLOW
Definition: libm_new.h:83
#define EXPSHIFTBITS_DP64
Definition: libm_util.h:56
#define GET_BITS_DP64(x, ux)
Definition: libm_util.h:118
#define BIASEDEMAX_DP64
Definition: libm_util.h:59
#define PINFBITPATT_SP32
Definition: libm_util.h:77
#define MANTBITS_DP64
Definition: libm_util.h:46
GLint dy
Definition: linetemp.h:97
GLint dx
Definition: linetemp.h:97
@ avx
Definition: optimize.h:112
int retval
Definition: wcstombs.cpp:91

Referenced by hypotf().

◆ _isnan()

_ACRTIMP int __cdecl _isnan ( double  num)

Definition at line 1660 of file math.c.

1661{
1662 union { double f; UINT64 i; } u = { num };
1663 return (u.i & ~0ull >> 1) > 0x7ffull << 52;
1664}

◆ _isnanf()

_ACRTIMP int __cdecl _isnanf ( float  num)

Definition at line 248 of file math.c.

249{
250 union { float f; UINT32 i; } u = { num };
251 return (u.i & 0x7fffffff) > 0x7f800000;
252}

Referenced by Test__isnanf().

◆ _j0()

_ACRTIMP double __cdecl _j0 ( double  num)

Definition at line 10 of file j0_y0.c.

11{
12 if (!_finite(num)) *_errno() = EDOM;
13 return __ieee754_j0(num);
14}
#define EDOM
Definition: errno.h:54
_ACRTIMP int __cdecl _finite(double)
Definition: math.c:1582
double __ieee754_j0(double)
Definition: j0_y0.c:102
int * _errno(void)
Definition: errno.c:215

Referenced by j0(), and test_j0().

◆ _j1()

_ACRTIMP double __cdecl _j1 ( double  num)

Definition at line 10 of file j1_y1.c.

11{
12 if (!_finite(num)) *_errno() = EDOM;
13 return __ieee754_j1(num);
14}
double __ieee754_j1(double)
Definition: j1_y1.c:103
int * _errno(void)
Definition: errno.c:215

Referenced by j1(), and test_j1().

◆ _jn()

_ACRTIMP double __cdecl _jn ( int  n,
double  num 
)

Definition at line 12 of file jn_yn.c.

13{
14 /* FIXME: errno handling */
15 return __ieee754_jn(n, num);
16}
GLdouble n
Definition: glext.h:7729
double __ieee754_jn(int, double)
Definition: jn_yn.c:64

Referenced by jn().

◆ _ldtest()

_ACRTIMP short __cdecl _ldtest ( long double )

◆ _logb()

_ACRTIMP double __cdecl _logb ( double  __x)

Definition at line 24 of file logb.c.

25{
26 register double __val;
27#ifdef __GNUC__
28 register double __junk;
29 __asm __volatile__
30 ("fxtract\n\t"
31 : "=t" (__junk), "=u" (__val) : "0" (__x));
32#else
33#pragma message ("REVIEW ME")
34 __asm fld [__x];
35 __asm fxtract;
36 __asm fstp st(0);
37 __asm fstp [__val];
38#endif /*__GNUC__*/
39 return __val;
40}
_STLP_INLINE_LOOP _InputIter const _Tp & __val
Definition: _algobase.h:656

◆ _logbf()

_ACRTIMP float __cdecl _logbf ( float  x)

Definition at line 38 of file logbf.c.

39{
40 unsigned int ux;
41 int u;
42 GET_BITS_SP32(x, ux);
44 if ((ux & ~SIGNBIT_SP32) == 0)
45 /* x is +/-zero. Return -infinity with div-by-zero flag. */
46 return _handle_errorf("_logbf", OP_LOGB, NINFBITPATT_SP32, _SING,
47 AMD_F_DIVBYZERO, ERANGE, x, 0.0F, 1);
48 else if (EMIN_SP32 <= u && u <= EMAX_SP32)
49 /* x is a normal number */
50 return (float)u;
51 else if (u > EMAX_SP32)
52 {
53 /* x is infinity or NaN */
54 if ((ux & MANTBITS_SP32) == 0)
55 /* x is +/-infinity. For VC++, return infinity of same sign. */
56 return x;
57 else
58 /* x is NaN, result is NaN */
59 return _handle_errorf("_logbf", OP_LOGB, ux|0x00400000, _DOMAIN,
60 0, EDOM, x, 0.0F, 1);
61 }
62 else
63 {
64 /* x is denormalized. */
65#ifdef FOLLOW_IEEE754_LOGB
66 /* Return the value of the minimum exponent to ensure that
67 the relationship between logb and scalb, defined in
68 IEEE 754, holds. */
69 return EMIN_SP32;
70#else
71 /* Follow the rule set by IEEE 854 for logb */
72 ux &= MANTBITS_SP32;
73 u = EMIN_SP32;
74 while (ux < IMPBIT_SP32)
75 {
76 ux <<= 1;
77 u--;
78 }
79 return (float)u;
80#endif
81 }
82}
#define _DOMAIN
Definition: math.h:20
#define _SING
Definition: math.h:21
#define AMD_F_DIVBYZERO
Definition: libm_new.h:85
#define EXPBITS_SP32
Definition: libm_util.h:69
#define EXPBIAS_SP32
Definition: libm_util.h:79
#define EMAX_SP32
Definition: libm_util.h:84
#define EMIN_SP32
Definition: libm_util.h:82
#define NINFBITPATT_SP32
Definition: libm_util.h:78
#define EXPSHIFTBITS_SP32
Definition: libm_util.h:80
#define MANTBITS_SP32
Definition: libm_util.h:70
#define IMPBIT_SP32
Definition: libm_util.h:74

◆ _matherr()

_ACRTIMP int __cdecl _matherr ( struct _exception e)

Definition at line 119 of file math.c.

120{
121 return 0;
122}

◆ _nextafter()

_ACRTIMP double __cdecl _nextafter ( double  ,
double   
)

◆ _scalb()

_ACRTIMP double __cdecl _scalb ( double  num,
__msvcrt_long  power 
)

Definition at line 2874 of file math.c.

2875{
2876 return ldexp(num, power);
2877}
double CDECL ldexp(double num, int exp)
Definition: math.c:1204
float power
Definition: d3drm.c:3372

◆ _y0()

_ACRTIMP double __cdecl _y0 ( double  num)

Definition at line 19 of file j0_y0.c.

20{
21 double retval;
22 int fpclass = _fpclass(num);
23
24 if (!_finite(num) || fpclass == _FPCLASS_NN ||
25 fpclass == _FPCLASS_ND || fpclass == _FPCLASS_NZ)
26 *_errno() = EDOM;
27
30 {
31 *_errno() = EDOM;
32 retval = sqrt(-1);
33 }
34 return retval;
35}
_ACRTIMP int __cdecl _fpclass(double)
Definition: math.c:595
double __ieee754_y0(double)
Definition: j0_y0.c:179

Referenced by test_y0(), and y0().

◆ _y1()

_ACRTIMP double __cdecl _y1 ( double  num)

Definition at line 19 of file j1_y1.c.

20{
21 double retval;
22 int fpclass = _fpclass(num);
23
24 if (!_finite(num) || fpclass == _FPCLASS_NN ||
25 fpclass == _FPCLASS_ND || fpclass == _FPCLASS_NZ)
26 *_errno() = EDOM;
27
30 {
31 *_errno() = EDOM;
32 retval = sqrt(-1);
33 }
34 return retval;
35}
double __ieee754_y1(double)
Definition: j1_y1.c:182

Referenced by test_y1(), and y1().

◆ _yn()

_ACRTIMP double __cdecl _yn ( int  order,
double  num 
)

Definition at line 21 of file jn_yn.c.

22{
23 double retval;
24 if (!_finite(num)) *_errno() = EDOM;
27 {
28 *_errno() = EDOM;
29 retval = sqrt(-1);
30 }
31 return retval;
32}
GLuint GLdouble GLdouble GLint GLint order
Definition: glext.h:11194
double __ieee754_yn(int, double)
Definition: jn_yn.c:227
fpclass_t _fpclass(double __d)
Definition: math.c:595
int * _errno(void)
Definition: errno.c:215

Referenced by yn().

◆ acos()

◆ acosf()

_ACRTIMP float __cdecl acosf ( float  x)

Definition at line 47 of file acosf.c.

48{
49 /* Computes arccos(x).
50 The argument is first reduced by noting that arccos(x)
51 is invalid for abs(x) > 1. For denormal and small
52 arguments arccos(x) = pi/2 to machine accuracy.
53 Remaining argument ranges are handled as follows.
54 For abs(x) <= 0.5 use
55 arccos(x) = pi/2 - arcsin(x)
56 = pi/2 - (x + x^3*R(x^2))
57 where R(x^2) is a rational minimax approximation to
58 (arcsin(x) - x)/x^3.
59 For abs(x) > 0.5 exploit the identity:
60 arccos(x) = pi - 2*arcsin(sqrt(1-x)/2)
61 together with the above rational approximation, and
62 reconstruct the terms carefully.
63 */
64
65 /* Some constants and split constants. */
66
67 static const float
68 piby2 = 1.5707963705e+00F; /* 0x3fc90fdb */
69 static const double
70 pi = 3.1415926535897933e+00, /* 0x400921fb54442d18 */
71 piby2_head = 1.5707963267948965580e+00, /* 0x3ff921fb54442d18 */
72 piby2_tail = 6.12323399573676603587e-17; /* 0x3c91a62633145c07 */
73
74 float u, y, s = 0.0F, r;
75 int xexp, xnan, transform = 0;
76
77 unsigned int ux, aux, xneg;
78
79 GET_BITS_SP32(x, ux);
80 aux = ux & ~SIGNBIT_SP32;
81 xneg = (ux & SIGNBIT_SP32);
82 xnan = (aux > PINFBITPATT_SP32);
83 xexp = (int)((ux & EXPBITS_SP32) >> EXPSHIFTBITS_SP32) - EXPBIAS_SP32;
84
85 /* Special cases */
86
87 if (xnan)
88 {
89 return _handle_errorf("acosf", OP_ACOS, ux|0x00400000, _DOMAIN, 0,
90 EDOM, x, 0.0F, 1);
91 }
92 else if (xexp < -26)
93 /* y small enough that arccos(x) = pi/2 */
94 return valf_with_flags(piby2, AMD_F_INEXACT);
95 else if (xexp >= 0)
96 { /* abs(x) >= 1.0 */
97 if (x == 1.0F)
98 return 0.0F;
99 else if (x == -1.0F)
100 return valf_with_flags((float)pi, AMD_F_INEXACT);
101 else
102 return _handle_errorf("acosf", OP_ACOS, INDEFBITPATT_SP32, _DOMAIN,
103 AMD_F_INVALID, EDOM, x, 0.0F, 1);
104 }
105
106 if (xneg) y = -x;
107 else y = x;
108
109 transform = (xexp >= -1); /* abs(x) >= 0.5 */
110
111 if (transform)
112 { /* Transform y into the range [0,0.5) */
113 r = 0.5F*(1.0F - y);
114 /* VC++ intrinsic call */
116 y = s;
117 }
118 else
119 r = y*y;
120
121 /* Use a rational approximation for [0.0, 0.5] */
122
123 u=r*(0.184161606965100694821398249421F +
124 (-0.0565298683201845211985026327361F +
125 (-0.0133819288943925804214011424456F -
126 0.00396137437848476485201154797087F*r)*r)*r)/
127 (1.10496961524520294485512696706F -
128 0.836411276854206731913362287293F*r);
129
130 if (transform)
131 {
132 /* Reconstruct acos carefully in transformed region */
133 if (xneg)
134 return (float)(pi - 2.0*(s+(y*u - piby2_tail)));
135 else
136 {
137 float c, s1;
138 unsigned int us;
140 PUT_BITS_SP32(0xffff0000 & us, s1);
141 c = (r-s1*s1)/(s+s1);
142 return 2.0F*s1 + (2.0F*c+2.0F*y*u);
143 }
144 }
145 else
146 return (float)(piby2_head - (x - (piby2_tail - x*u)));
147}
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31
GLuint GLenum GLenum transform
Definition: glext.h:9407
const GLubyte * c
Definition: glext.h:8905
#define c
Definition: ke_i.h:80
#define AMD_F_INVALID
Definition: libm_new.h:86
#define INDEFBITPATT_SP32
Definition: libm_util.h:76
struct S1 s1
static const BYTE us[]
Definition: encode.c:671
static PROCESS_INFORMATION pi
Definition: debugger.c:2303
void _mm_store_ss(float *p, __m128 a)
Definition: xmmintrin.h:1052
__m128 _mm_load_ss(float const *p)
Definition: xmmintrin.h:956
__m128 _mm_sqrt_ss(__m128 a)
Definition: xmmintrin.h:592

Referenced by D3DXComputeTangentFrameEx(), D3DXQuaternionLn(), D3DXQuaternionSlerp(), D3DXQuaternionToAxisAngle(), Test_acosf_approx(), and Test_acosf_exact().

◆ acosh()

_ACRTIMP double __cdecl acosh ( double  x)

Definition at line 54 of file fun_ieee.c.

55{
56 // must be x>=1, if not return Nan (Not a Number)
57 if(!(x>=1.0)) return sqrt(-1.0);
58
59 // return only the positive result (as sqrt does).
60 return log(x+sqrt(x*x-1.0));
61}
#define log(outFile, fmt,...)
Definition: util.h:15

◆ acoshf()

_ACRTIMP float __cdecl acoshf ( float  )

◆ asin()

Definition at line 31 of file asin.c.

32{
33 double x2, result;
34
35 /* Check range */
36 if ((x > 1.) || (x < -1.)) return NaN;
37
38 /* Calculate the square of x */
39 x2 = (x * x);
40
41 /* Start with 0, compiler will optimize this away */
42 result = 0;
43
44 result += (15*13*11*9*7*5*3*1./(16*14*12*10*8*6*4*2*17));
45 result *= x2;
46
47 result += (13*11*9*7*5*3*1./(14*12*10*8*6*4*2*15));
48 result *= x2;
49
50 result += (11*9*7*5*3*1./(12*10*8*6*4*2*13));
51 result *= x2;
52
53 result += (9*7*5*3*1./(10*8*6*4*2*11));
54 result *= x2;
55
56 result += (7*5*3*1./(8*6*4*2*9));
57 result *= x2;
58
59 result += (5*3*1./(6*4*2*7));
60 result *= x2;
61
62 result += (3*1./(4*2*5));
63 result *= x2;
64
65 result += (1./(2*3));
66 result *= x2;
67
68 result += 1.;
69 result *= x;
70
71 return result;
72}
GLuint64EXT * result
Definition: glext.h:11304
_In_ CLIPOBJ _In_ BRUSHOBJ _In_ LONG _In_ LONG _In_ LONG x2
Definition: winddi.h:3710

Referenced by __libm_sse2_asin(), __libm_sse2_asinf(), _CIasin(), _libm_sse2_asin_precise(), asinf(), asinl(), Math_asin(), MSVCRT_asin(), pres_asin(), rpn_asin(), Test_asin_approx(), Test_asin_exact(), and ValarrayTest::transcendentals().

◆ asinf()

_ACRTIMP float __cdecl asinf ( float  x)

Definition at line 47 of file asinf.c.

48{
49 /* Computes arcsin(x).
50 The argument is first reduced by noting that arcsin(x)
51 is invalid for abs(x) > 1 and arcsin(-x) = -arcsin(x).
52 For denormal and small arguments arcsin(x) = x to machine
53 accuracy. Remaining argument ranges are handled as follows.
54 For abs(x) <= 0.5 use
55 arcsin(x) = x + x^3*R(x^2)
56 where R(x^2) is a rational minimax approximation to
57 (arcsin(x) - x)/x^3.
58 For abs(x) > 0.5 exploit the identity:
59 arcsin(x) = pi/2 - 2*arcsin(sqrt(1-x)/2)
60 together with the above rational approximation, and
61 reconstruct the terms carefully.
62 */
63
64 /* Some constants and split constants. */
65
66 static const float
67 piby2_tail = 7.5497894159e-08F, /* 0x33a22168 */
68 hpiby2_head = 7.8539812565e-01F, /* 0x3f490fda */
69 piby2 = 1.5707963705e+00F; /* 0x3fc90fdb */
70 float u, v, y, s = 0.0F, r;
71 int xexp, xnan, transform = 0;
72
73 unsigned int ux, aux, xneg;
74 GET_BITS_SP32(x, ux);
75 aux = ux & ~SIGNBIT_SP32;
76 xneg = (ux & SIGNBIT_SP32);
77 xnan = (aux > PINFBITPATT_SP32);
78 xexp = (int)((ux & EXPBITS_SP32) >> EXPSHIFTBITS_SP32) - EXPBIAS_SP32;
79
80 /* Special cases */
81
82 if (xnan)
83 {
84 return _handle_errorf("asinf", OP_ASIN, ux|0x00400000, _DOMAIN, 0,
85 EDOM, x, 0.0F, 1);
86 }
87 else if (xexp < -14)
88 /* y small enough that arcsin(x) = x */
89 return valf_with_flags(x, AMD_F_INEXACT);
90 else if (xexp >= 0)
91 {
92 /* abs(x) >= 1.0 */
93 if (x == 1.0F)
94 return valf_with_flags(piby2, AMD_F_INEXACT);
95 else if (x == -1.0F)
96 return valf_with_flags(-piby2, AMD_F_INEXACT);
97 else
98 return _handle_errorf("asinf", OP_ASIN, INDEFBITPATT_SP32, _DOMAIN,
99 AMD_F_INVALID, EDOM, x, 0.0F, 1);
100 }
101
102 if (xneg) y = -x;
103 else y = x;
104
105 transform = (xexp >= -1); /* abs(x) >= 0.5 */
106
107 if (transform)
108 { /* Transform y into the range [0,0.5) */
109 r = 0.5F*(1.0F - y);
110 /* VC++ intrinsic call */
112 y = s;
113 }
114 else
115 r = y*y;
116
117 /* Use a rational approximation for [0.0, 0.5] */
118
119 u=r*(0.184161606965100694821398249421F +
120 (-0.0565298683201845211985026327361F +
121 (-0.0133819288943925804214011424456F -
122 0.00396137437848476485201154797087F*r)*r)*r)/
123 (1.10496961524520294485512696706F -
124 0.836411276854206731913362287293F*r);
125
126 if (transform)
127 {
128 /* Reconstruct asin carefully in transformed region */
129 float c, s1, p, q;
130 unsigned int us;
132 PUT_BITS_SP32(0xffff0000 & us, s1);
133 c = (r-s1*s1)/(s+s1);
134 p = 2.0F*s*u - (piby2_tail-2.0F*c);
135 q = hpiby2_head - 2.0F*s1;
136 v = hpiby2_head - (p-q);
137 }
138 else
139 {
140 /* Use a temporary variable to prevent VC++ rearranging
141 y + y*u
142 into
143 y * (1 + u)
144 and getting an incorrectly rounded result */
145 float tmp;
146 tmp = y * u;
147 v = y + tmp;
148 }
149
150 if (xneg) return -v;
151 else return v;
152}
const GLdouble * v
Definition: gl.h:2040

Referenced by D3DXSHEvalSphericalLight(), Test_asinf_approx(), and Test_asinf_exact().

◆ asinh()

_ACRTIMP double __cdecl asinh ( double  x)

Definition at line 49 of file fun_ieee.c.

50{
51 return log(x+sqrt(x*x+1));
52}

◆ asinhf()

_ACRTIMP float __cdecl asinhf ( float  )

◆ atan()

Definition at line 44 of file atan.c.

45{
46
47 /* Some constants and split constants. */
48
49 static double piby2 = 1.5707963267948966e+00; /* 0x3ff921fb54442d18 */
50 double chi, clo, v, s, q, z;
51
52 /* Find properties of argument x. */
53
54 unsigned long long ux, aux, xneg;
55 GET_BITS_DP64(x, ux);
56 aux = ux & ~SIGNBIT_DP64;
57 xneg = (ux != aux);
58
59 if (xneg) v = -x;
60 else v = x;
61
62 /* Argument reduction to range [-7/16,7/16] */
63
64 if (aux > 0x4003800000000000) /* v > 39./16. */
65 {
66
67 if (aux > PINFBITPATT_DP64)
68 {
69 /* x is NaN */
70 return _handle_error("atan", OP_ATAN, ux|0x0008000000000000, _DOMAIN, 0,
71 EDOM, x, 0.0, 1);
72 }
73 else if (v > 0x4370000000000000)
74 { /* abs(x) > 2^56 => arctan(1/x) is
75 insignificant compared to piby2 */
76 if (xneg)
77 return val_with_flags(-piby2, AMD_F_INEXACT);
78 else
79 return val_with_flags(piby2, AMD_F_INEXACT);
80 }
81
82 x = -1.0/v;
83 /* (chi + clo) = arctan(infinity) */
84 chi = 1.57079632679489655800e+00; /* 0x3ff921fb54442d18 */
85 clo = 6.12323399573676480327e-17; /* 0x3c91a62633145c06 */
86 }
87 else if (aux > 0x3ff3000000000000) /* 39./16. > v > 19./16. */
88 {
89 x = (v-1.5)/(1.0+1.5*v);
90 /* (chi + clo) = arctan(1.5) */
91 chi = 9.82793723247329054082e-01; /* 0x3fef730bd281f69b */
92 clo = 1.39033110312309953701e-17; /* 0x3c7007887af0cbbc */
93 }
94 else if (aux > 0x3fe6000000000000) /* 19./16. > v > 11./16. */
95 {
96 x = (v-1.0)/(1.0+v);
97 /* (chi + clo) = arctan(1.) */
98 chi = 7.85398163397448278999e-01; /* 0x3fe921fb54442d18 */
99 clo = 3.06161699786838240164e-17; /* 0x3c81a62633145c06 */
100 }
101 else if (aux > 0x3fdc000000000000) /* 11./16. > v > 7./16. */
102 {
103 x = (2.0*v-1.0)/(2.0+v);
104 /* (chi + clo) = arctan(0.5) */
105 chi = 4.63647609000806093515e-01; /* 0x3fddac670561bb4f */
106 clo = 2.26987774529616809294e-17; /* 0x3c7a2b7f222f65e0 */
107 }
108 else /* v < 7./16. */
109 {
110 x = v;
111 chi = 0.0;
112 clo = 0.0;
113 }
114
115 /* Core approximation: Remez(4,4) on [-7/16,7/16] */
116
117 s = x*x;
118 q = x*s*
119 (0.268297920532545909e0 +
120 (0.447677206805497472e0 +
121 (0.220638780716667420e0 +
122 (0.304455919504853031e-1 +
123 0.142316903342317766e-3*s)*s)*s)*s)/
124 (0.804893761597637733e0 +
125 (0.182596787737507063e1 +
126 (0.141254259931958921e1 +
127 (0.424602594203847109e0 +
128 0.389525873944742195e-1*s)*s)*s)*s);
129
130 z = chi - ((q - clo) - x);
131
132 if (xneg) z = -z;
133 return z;
134}
double __cdecl _handle_error(char *fname, int opcode, unsigned long long value, int type, int flags, int error, double arg1, double arg2, int nargs)
Handles an error condition.
Definition: _handle_error.c:34
GLdouble GLdouble z
Definition: glext.h:5874
#define PINFBITPATT_DP64
Definition: libm_util.h:53

Referenced by __libm_sse2_atan(), __libm_sse2_atanf(), _CIatan(), _libm_sse2_atan_precise(), atanf(), atanl(), GdipCreateLineBrushFromRectWithAngle(), Global_Atn(), Math_atan(), MSVCRT_atan(), pres_atan(), rpn_atan(), Test_atan_approx(), Test_atan_exact(), and ValarrayTest::transcendentals().

◆ atan2()

_ACRTIMP double __cdecl atan2 ( double  y,
double  x 
)

Definition at line 52 of file atan2.c.

53{
54 /* Arrays atan_jby256_lead and atan_jby256_tail contain
55 leading and trailing parts respectively of precomputed
56 values of atan(j/256), for j = 16, 17, ..., 256.
57 atan_jby256_lead contains the first 21 bits of precision,
58 and atan_jby256_tail contains a further 53 bits precision. */
59
60 static const double atan_jby256_lead[ 241] = {
61 6.24187886714935302734e-02, /* 0x3faff55b00000000 */
62 6.63088560104370117188e-02, /* 0x3fb0f99e00000000 */
63 7.01969265937805175781e-02, /* 0x3fb1f86d00000000 */
64 7.40829110145568847656e-02, /* 0x3fb2f71900000000 */
65 7.79666304588317871094e-02, /* 0x3fb3f59f00000000 */
66 8.18479657173156738281e-02, /* 0x3fb4f3fd00000000 */
67 8.57268571853637695312e-02, /* 0x3fb5f23200000000 */
68 8.96031260490417480469e-02, /* 0x3fb6f03b00000000 */
69 9.34767723083496093750e-02, /* 0x3fb7ee1800000000 */
70 9.73475575447082519531e-02, /* 0x3fb8ebc500000000 */
71 1.01215422153472900391e-01, /* 0x3fb9e94100000000 */
72 1.05080246925354003906e-01, /* 0x3fbae68a00000000 */
73 1.08941912651062011719e-01, /* 0x3fbbe39e00000000 */
74 1.12800359725952148438e-01, /* 0x3fbce07c00000000 */
75 1.16655409336090087891e-01, /* 0x3fbddd2100000000 */
76 1.20507001876831054688e-01, /* 0x3fbed98c00000000 */
77 1.24354958534240722656e-01, /* 0x3fbfd5ba00000000 */
78 1.28199219703674316406e-01, /* 0x3fc068d500000000 */
79 1.32039666175842285156e-01, /* 0x3fc0e6ad00000000 */
80 1.35876297950744628906e-01, /* 0x3fc1646500000000 */
81 1.39708757400512695312e-01, /* 0x3fc1e1fa00000000 */
82 1.43537282943725585938e-01, /* 0x3fc25f6e00000000 */
83 1.47361397743225097656e-01, /* 0x3fc2dcbd00000000 */
84 1.51181221008300781250e-01, /* 0x3fc359e800000000 */
85 1.54996633529663085938e-01, /* 0x3fc3d6ee00000000 */
86 1.58807516098022460938e-01, /* 0x3fc453ce00000000 */
87 1.62613749504089355469e-01, /* 0x3fc4d08700000000 */
88 1.66415214538574218750e-01, /* 0x3fc54d1800000000 */
89 1.70211911201477050781e-01, /* 0x3fc5c98100000000 */
90 1.74003481864929199219e-01, /* 0x3fc645bf00000000 */
91 1.77790164947509765625e-01, /* 0x3fc6c1d400000000 */
92 1.81571602821350097656e-01, /* 0x3fc73dbd00000000 */
93 1.85347914695739746094e-01, /* 0x3fc7b97b00000000 */
94 1.89118742942810058594e-01, /* 0x3fc8350b00000000 */
95 1.92884206771850585938e-01, /* 0x3fc8b06e00000000 */
96 1.96644186973571777344e-01, /* 0x3fc92ba300000000 */
97 2.00398445129394531250e-01, /* 0x3fc9a6a800000000 */
98 2.04147100448608398438e-01, /* 0x3fca217e00000000 */
99 2.07889914512634277344e-01, /* 0x3fca9c2300000000 */
100 2.11626768112182617188e-01, /* 0x3fcb169600000000 */
101 2.15357661247253417969e-01, /* 0x3fcb90d700000000 */
102 2.19082474708557128906e-01, /* 0x3fcc0ae500000000 */
103 2.22801089286804199219e-01, /* 0x3fcc84bf00000000 */
104 2.26513504981994628906e-01, /* 0x3fccfe6500000000 */
105 2.30219483375549316406e-01, /* 0x3fcd77d500000000 */
106 2.33919143676757812500e-01, /* 0x3fcdf11000000000 */
107 2.37612247467041015625e-01, /* 0x3fce6a1400000000 */
108 2.41298794746398925781e-01, /* 0x3fcee2e100000000 */
109 2.44978547096252441406e-01, /* 0x3fcf5b7500000000 */
110 2.48651623725891113281e-01, /* 0x3fcfd3d100000000 */
111 2.52317905426025390625e-01, /* 0x3fd025fa00000000 */
112 2.55977153778076171875e-01, /* 0x3fd061ee00000000 */
113 2.59629487991333007812e-01, /* 0x3fd09dc500000000 */
114 2.63274669647216796875e-01, /* 0x3fd0d97e00000000 */
115 2.66912937164306640625e-01, /* 0x3fd1151a00000000 */
116 2.70543813705444335938e-01, /* 0x3fd1509700000000 */
117 2.74167299270629882812e-01, /* 0x3fd18bf500000000 */
118 2.77783632278442382812e-01, /* 0x3fd1c73500000000 */
119 2.81392335891723632812e-01, /* 0x3fd2025500000000 */
120 2.84993648529052734375e-01, /* 0x3fd23d5600000000 */
121 2.88587331771850585938e-01, /* 0x3fd2783700000000 */
122 2.92173147201538085938e-01, /* 0x3fd2b2f700000000 */
123 2.95751571655273437500e-01, /* 0x3fd2ed9800000000 */
124 2.99322128295898437500e-01, /* 0x3fd3281800000000 */
125 3.02884817123413085938e-01, /* 0x3fd3627700000000 */
126 3.06439399719238281250e-01, /* 0x3fd39cb400000000 */
127 3.09986352920532226562e-01, /* 0x3fd3d6d100000000 */
128 3.13524961471557617188e-01, /* 0x3fd410cb00000000 */
129 3.17055702209472656250e-01, /* 0x3fd44aa400000000 */
130 3.20578098297119140625e-01, /* 0x3fd4845a00000000 */
131 3.24092388153076171875e-01, /* 0x3fd4bdee00000000 */
132 3.27598333358764648438e-01, /* 0x3fd4f75f00000000 */
133 3.31095933914184570312e-01, /* 0x3fd530ad00000000 */
134 3.34585189819335937500e-01, /* 0x3fd569d800000000 */
135 3.38066101074218750000e-01, /* 0x3fd5a2e000000000 */
136 3.41538190841674804688e-01, /* 0x3fd5dbc300000000 */
137 3.45002174377441406250e-01, /* 0x3fd6148400000000 */
138 3.48457098007202148438e-01, /* 0x3fd64d1f00000000 */
139 3.51903676986694335938e-01, /* 0x3fd6859700000000 */
140 3.55341434478759765625e-01, /* 0x3fd6bdea00000000 */
141 3.58770608901977539062e-01, /* 0x3fd6f61900000000 */
142 3.62190723419189453125e-01, /* 0x3fd72e2200000000 */
143 3.65602254867553710938e-01, /* 0x3fd7660700000000 */
144 3.69004726409912109375e-01, /* 0x3fd79dc600000000 */
145 3.72398376464843750000e-01, /* 0x3fd7d56000000000 */
146 3.75782966613769531250e-01, /* 0x3fd80cd400000000 */
147 3.79158496856689453125e-01, /* 0x3fd8442200000000 */
148 3.82525205612182617188e-01, /* 0x3fd87b4b00000000 */
149 3.85882616043090820312e-01, /* 0x3fd8b24d00000000 */
150 3.89230966567993164062e-01, /* 0x3fd8e92900000000 */
151 3.92570018768310546875e-01, /* 0x3fd91fde00000000 */
152 3.95900011062622070312e-01, /* 0x3fd9566d00000000 */
153 3.99220705032348632812e-01, /* 0x3fd98cd500000000 */
154 4.02532100677490234375e-01, /* 0x3fd9c31600000000 */
155 4.05834197998046875000e-01, /* 0x3fd9f93000000000 */
156 4.09126996994018554688e-01, /* 0x3fda2f2300000000 */
157 4.12410259246826171875e-01, /* 0x3fda64ee00000000 */
158 4.15684223175048828125e-01, /* 0x3fda9a9200000000 */
159 4.18948888778686523438e-01, /* 0x3fdad00f00000000 */
160 4.22204017639160156250e-01, /* 0x3fdb056400000000 */
161 4.25449609756469726562e-01, /* 0x3fdb3a9100000000 */
162 4.28685665130615234375e-01, /* 0x3fdb6f9600000000 */
163 4.31912183761596679688e-01, /* 0x3fdba47300000000 */
164 4.35129165649414062500e-01, /* 0x3fdbd92800000000 */
165 4.38336372375488281250e-01, /* 0x3fdc0db400000000 */
166 4.41534280776977539062e-01, /* 0x3fdc421900000000 */
167 4.44722414016723632812e-01, /* 0x3fdc765500000000 */
168 4.47900772094726562500e-01, /* 0x3fdcaa6800000000 */
169 4.51069593429565429688e-01, /* 0x3fdcde5300000000 */
170 4.54228639602661132812e-01, /* 0x3fdd121500000000 */
171 4.57377910614013671875e-01, /* 0x3fdd45ae00000000 */
172 4.60517644882202148438e-01, /* 0x3fdd791f00000000 */
173 4.63647603988647460938e-01, /* 0x3fddac6700000000 */
174 4.66767549514770507812e-01, /* 0x3fdddf8500000000 */
175 4.69877958297729492188e-01, /* 0x3fde127b00000000 */
176 4.72978591918945312500e-01, /* 0x3fde454800000000 */
177 4.76069211959838867188e-01, /* 0x3fde77eb00000000 */
178 4.79150056838989257812e-01, /* 0x3fdeaa6500000000 */
179 4.82221126556396484375e-01, /* 0x3fdedcb600000000 */
180 4.85282421112060546875e-01, /* 0x3fdf0ede00000000 */
181 4.88333940505981445312e-01, /* 0x3fdf40dd00000000 */
182 4.91375446319580078125e-01, /* 0x3fdf72b200000000 */
183 4.94406938552856445312e-01, /* 0x3fdfa45d00000000 */
184 4.97428894042968750000e-01, /* 0x3fdfd5e000000000 */
185 5.00440597534179687500e-01, /* 0x3fe0039c00000000 */
186 5.03442764282226562500e-01, /* 0x3fe01c3400000000 */
187 5.06434917449951171875e-01, /* 0x3fe034b700000000 */
188 5.09417057037353515625e-01, /* 0x3fe04d2500000000 */
189 5.12389183044433593750e-01, /* 0x3fe0657e00000000 */
190 5.15351772308349609375e-01, /* 0x3fe07dc300000000 */
191 5.18304347991943359375e-01, /* 0x3fe095f300000000 */
192 5.21246910095214843750e-01, /* 0x3fe0ae0e00000000 */
193 5.24179458618164062500e-01, /* 0x3fe0c61400000000 */
194 5.27101993560791015625e-01, /* 0x3fe0de0500000000 */
195 5.30014991760253906250e-01, /* 0x3fe0f5e200000000 */
196 5.32917976379394531250e-01, /* 0x3fe10daa00000000 */
197 5.35810947418212890625e-01, /* 0x3fe1255d00000000 */
198 5.38693904876708984375e-01, /* 0x3fe13cfb00000000 */
199 5.41567325592041015625e-01, /* 0x3fe1548500000000 */
200 5.44430732727050781250e-01, /* 0x3fe16bfa00000000 */
201 5.47284126281738281250e-01, /* 0x3fe1835a00000000 */
202 5.50127506256103515625e-01, /* 0x3fe19aa500000000 */
203 5.52961349487304687500e-01, /* 0x3fe1b1dc00000000 */
204 5.55785179138183593750e-01, /* 0x3fe1c8fe00000000 */
205 5.58598995208740234375e-01, /* 0x3fe1e00b00000000 */
206 5.61403274536132812500e-01, /* 0x3fe1f70400000000 */
207 5.64197540283203125000e-01, /* 0x3fe20de800000000 */
208 5.66981792449951171875e-01, /* 0x3fe224b700000000 */
209 5.69756031036376953125e-01, /* 0x3fe23b7100000000 */
210 5.72520732879638671875e-01, /* 0x3fe2521700000000 */
211 5.75275897979736328125e-01, /* 0x3fe268a900000000 */
212 5.78021049499511718750e-01, /* 0x3fe27f2600000000 */
213 5.80756187438964843750e-01, /* 0x3fe2958e00000000 */
214 5.83481788635253906250e-01, /* 0x3fe2abe200000000 */
215 5.86197376251220703125e-01, /* 0x3fe2c22100000000 */
216 5.88903427124023437500e-01, /* 0x3fe2d84c00000000 */
217 5.91599464416503906250e-01, /* 0x3fe2ee6200000000 */
218 5.94285964965820312500e-01, /* 0x3fe3046400000000 */
219 5.96962928771972656250e-01, /* 0x3fe31a5200000000 */
220 5.99629878997802734375e-01, /* 0x3fe3302b00000000 */
221 6.02287292480468750000e-01, /* 0x3fe345f000000000 */
222 6.04934692382812500000e-01, /* 0x3fe35ba000000000 */
223 6.07573032379150390625e-01, /* 0x3fe3713d00000000 */
224 6.10201358795166015625e-01, /* 0x3fe386c500000000 */
225 6.12820148468017578125e-01, /* 0x3fe39c3900000000 */
226 6.15428924560546875000e-01, /* 0x3fe3b19800000000 */
227 6.18028640747070312500e-01, /* 0x3fe3c6e400000000 */
228 6.20618820190429687500e-01, /* 0x3fe3dc1c00000000 */
229 6.23198986053466796875e-01, /* 0x3fe3f13f00000000 */
230 6.25770092010498046875e-01, /* 0x3fe4064f00000000 */
231 6.28331184387207031250e-01, /* 0x3fe41b4a00000000 */
232 6.30883216857910156250e-01, /* 0x3fe4303200000000 */
233 6.33425712585449218750e-01, /* 0x3fe4450600000000 */
234 6.35958671569824218750e-01, /* 0x3fe459c600000000 */
235 6.38482093811035156250e-01, /* 0x3fe46e7200000000 */
236 6.40995979309082031250e-01, /* 0x3fe4830a00000000 */
237 6.43500804901123046875e-01, /* 0x3fe4978f00000000 */
238 6.45996093750000000000e-01, /* 0x3fe4ac0000000000 */
239 6.48482322692871093750e-01, /* 0x3fe4c05e00000000 */
240 6.50959014892578125000e-01, /* 0x3fe4d4a800000000 */
241 6.53426170349121093750e-01, /* 0x3fe4e8de00000000 */
242 6.55884265899658203125e-01, /* 0x3fe4fd0100000000 */
243 6.58332824707031250000e-01, /* 0x3fe5111000000000 */
244 6.60772323608398437500e-01, /* 0x3fe5250c00000000 */
245 6.63202762603759765625e-01, /* 0x3fe538f500000000 */
246 6.65623664855957031250e-01, /* 0x3fe54cca00000000 */
247 6.68035984039306640625e-01, /* 0x3fe5608d00000000 */
248 6.70438766479492187500e-01, /* 0x3fe5743c00000000 */
249 6.72832489013671875000e-01, /* 0x3fe587d800000000 */
250 6.75216674804687500000e-01, /* 0x3fe59b6000000000 */
251 6.77592277526855468750e-01, /* 0x3fe5aed600000000 */
252 6.79958820343017578125e-01, /* 0x3fe5c23900000000 */
253 6.82316303253173828125e-01, /* 0x3fe5d58900000000 */
254 6.84664726257324218750e-01, /* 0x3fe5e8c600000000 */
255 6.87004089355468750000e-01, /* 0x3fe5fbf000000000 */
256 6.89334869384765625000e-01, /* 0x3fe60f0800000000 */
257 6.91656589508056640625e-01, /* 0x3fe6220d00000000 */
258 6.93969249725341796875e-01, /* 0x3fe634ff00000000 */
259 6.96272850036621093750e-01, /* 0x3fe647de00000000 */
260 6.98567867279052734375e-01, /* 0x3fe65aab00000000 */
261 7.00854301452636718750e-01, /* 0x3fe66d6600000000 */
262 7.03131675720214843750e-01, /* 0x3fe6800e00000000 */
263 7.05400466918945312500e-01, /* 0x3fe692a400000000 */
264 7.07660198211669921875e-01, /* 0x3fe6a52700000000 */
265 7.09911346435546875000e-01, /* 0x3fe6b79800000000 */
266 7.12153911590576171875e-01, /* 0x3fe6c9f700000000 */
267 7.14387893676757812500e-01, /* 0x3fe6dc4400000000 */
268 7.16613292694091796875e-01, /* 0x3fe6ee7f00000000 */
269 7.18829631805419921875e-01, /* 0x3fe700a700000000 */
270 7.21037864685058593750e-01, /* 0x3fe712be00000000 */
271 7.23237514495849609375e-01, /* 0x3fe724c300000000 */
272 7.25428581237792968750e-01, /* 0x3fe736b600000000 */
273 7.27611064910888671875e-01, /* 0x3fe7489700000000 */
274 7.29785442352294921875e-01, /* 0x3fe75a6700000000 */
275 7.31950759887695312500e-01, /* 0x3fe76c2400000000 */
276 7.34108448028564453125e-01, /* 0x3fe77dd100000000 */
277 7.36257076263427734375e-01, /* 0x3fe78f6b00000000 */
278 7.38397598266601562500e-01, /* 0x3fe7a0f400000000 */
279 7.40530014038085937500e-01, /* 0x3fe7b26c00000000 */
280 7.42654323577880859375e-01, /* 0x3fe7c3d300000000 */
281 7.44770050048828125000e-01, /* 0x3fe7d52800000000 */
282 7.46877670288085937500e-01, /* 0x3fe7e66c00000000 */
283 7.48976707458496093750e-01, /* 0x3fe7f79e00000000 */
284 7.51068115234375000000e-01, /* 0x3fe808c000000000 */
285 7.53150939941406250000e-01, /* 0x3fe819d000000000 */
286 7.55226135253906250000e-01, /* 0x3fe82ad000000000 */
287 7.57292747497558593750e-01, /* 0x3fe83bbe00000000 */
288 7.59351730346679687500e-01, /* 0x3fe84c9c00000000 */
289 7.61402606964111328125e-01, /* 0x3fe85d6900000000 */
290 7.63445377349853515625e-01, /* 0x3fe86e2500000000 */
291 7.65480041503906250000e-01, /* 0x3fe87ed000000000 */
292 7.67507076263427734375e-01, /* 0x3fe88f6b00000000 */
293 7.69526004791259765625e-01, /* 0x3fe89ff500000000 */
294 7.71537303924560546875e-01, /* 0x3fe8b06f00000000 */
295 7.73540973663330078125e-01, /* 0x3fe8c0d900000000 */
296 7.75536537170410156250e-01, /* 0x3fe8d13200000000 */
297 7.77523994445800781250e-01, /* 0x3fe8e17a00000000 */
298 7.79504299163818359375e-01, /* 0x3fe8f1b300000000 */
299 7.81476497650146484375e-01, /* 0x3fe901db00000000 */
300 7.83441066741943359375e-01, /* 0x3fe911f300000000 */
301 7.85398006439208984375e-01}; /* 0x3fe921fb00000000 */
302
303 static const double atan_jby256_tail[ 241] = {
304 2.13244638182005395671e-08, /* 0x3e56e59fbd38db2c */
305 3.89093864761712760656e-08, /* 0x3e64e3aa54dedf96 */
306 4.44780900009437454576e-08, /* 0x3e67e105ab1bda88 */
307 1.15344768460112754160e-08, /* 0x3e48c5254d013fd0 */
308 3.37271051945395312705e-09, /* 0x3e2cf8ab3ad62670 */
309 2.40857608736109859459e-08, /* 0x3e59dca4bec80468 */
310 1.85853810450623807768e-08, /* 0x3e53f4b5ec98a8da */
311 5.14358299969225078306e-08, /* 0x3e6b9d49619d81fe */
312 8.85023985412952486748e-09, /* 0x3e43017887460934 */
313 1.59425154214358432060e-08, /* 0x3e511e3eca0b9944 */
314 1.95139937737755753164e-08, /* 0x3e54f3f73c5a332e */
315 2.64909755273544319715e-08, /* 0x3e5c71c8ae0e00a6 */
316 4.43388037881231070144e-08, /* 0x3e67cde0f86fbdc7 */
317 2.14757072421821274557e-08, /* 0x3e570f328c889c72 */
318 2.61049792670754218852e-08, /* 0x3e5c07ae9b994efe */
319 7.81439350674466302231e-09, /* 0x3e40c8021d7b1698 */
320 3.60125207123751024094e-08, /* 0x3e635585edb8cb22 */
321 6.15276238179343767917e-08, /* 0x3e70842567b30e96 */
322 9.54387964641184285058e-08, /* 0x3e799e811031472e */
323 3.02789566851502754129e-08, /* 0x3e6041821416bcee */
324 1.16888650949870856331e-07, /* 0x3e7f6086e4dc96f4 */
325 1.07580956468653338863e-08, /* 0x3e471a535c5f1b58 */
326 8.33454265379535427653e-08, /* 0x3e765f743fe63ca1 */
327 1.10790279272629526068e-07, /* 0x3e7dbd733472d014 */
328 1.08394277896366207424e-07, /* 0x3e7d18cc4d8b0d1d */
329 9.22176086126841098800e-08, /* 0x3e78c12553c8fb29 */
330 7.90938592199048786990e-08, /* 0x3e753b49e2e8f991 */
331 8.66445407164293125637e-08, /* 0x3e77422ae148c141 */
332 1.40839973537092438671e-08, /* 0x3e4e3ec269df56a8 */
333 1.19070438507307600689e-07, /* 0x3e7ff6754e7e0ac9 */
334 6.40451663051716197071e-08, /* 0x3e7131267b1b5aad */
335 1.08338682076343674522e-07, /* 0x3e7d14fa403a94bc */
336 3.52999550187922736222e-08, /* 0x3e62f396c089a3d8 */
337 1.05983273930043077202e-07, /* 0x3e7c731d78fa95bb */
338 1.05486124078259553339e-07, /* 0x3e7c50f385177399 */
339 5.82167732281776477773e-08, /* 0x3e6f41409c6f2c20 */
340 1.08696483983403942633e-07, /* 0x3e7d2d90c4c39ec0 */
341 4.47335086122377542835e-08, /* 0x3e680420696f2106 */
342 1.26896287162615723528e-08, /* 0x3e4b40327943a2e8 */
343 4.06534471589151404531e-08, /* 0x3e65d35e02f3d2a2 */
344 3.84504846300557026690e-08, /* 0x3e64a498288117b0 */
345 3.60715006404807269080e-08, /* 0x3e635da119afb324 */
346 6.44725903165522722801e-08, /* 0x3e714e85cdb9a908 */
347 3.63749249976409461305e-08, /* 0x3e638754e5547b9a */
348 1.03901294413833913794e-07, /* 0x3e7be40ae6ce3246 */
349 6.25379756302167880580e-08, /* 0x3e70c993b3bea7e7 */
350 6.63984302368488828029e-08, /* 0x3e71d2dd89ac3359 */
351 3.21844598971548278059e-08, /* 0x3e61476603332c46 */
352 1.16030611712765830905e-07, /* 0x3e7f25901bac55b7 */
353 1.17464622142347730134e-07, /* 0x3e7f881b7c826e28 */
354 7.54604017965808996596e-08, /* 0x3e7441996d698d20 */
355 1.49234929356206556899e-07, /* 0x3e8407ac521ea089 */
356 1.41416924523217430259e-07, /* 0x3e82fb0c6c4b1723 */
357 2.13308065617483489011e-07, /* 0x3e8ca135966a3e18 */
358 5.04230937933302320146e-08, /* 0x3e6b1218e4d646e4 */
359 5.45874922281655519035e-08, /* 0x3e6d4e72a350d288 */
360 1.51849028914786868886e-07, /* 0x3e84617e2f04c329 */
361 3.09004308703769273010e-08, /* 0x3e6096ec41e82650 */
362 9.67574548184738317664e-08, /* 0x3e79f91f25773e6e */
363 4.02508285529322212824e-08, /* 0x3e659c0820f1d674 */
364 3.01222268096861091157e-08, /* 0x3e602bf7a2df1064 */
365 2.36189860670079288680e-07, /* 0x3e8fb36bfc40508f */
366 1.14095158111080887695e-07, /* 0x3e7ea08f3f8dc892 */
367 7.42349089746573467487e-08, /* 0x3e73ed6254656a0e */
368 5.12515583196230380184e-08, /* 0x3e6b83f5e5e69c58 */
369 2.19290391828763918102e-07, /* 0x3e8d6ec2af768592 */
370 3.83263512187553886471e-08, /* 0x3e6493889a226f94 */
371 1.61513486284090523855e-07, /* 0x3e85ad8fa65279ba */
372 5.09996743535589922261e-08, /* 0x3e6b615784d45434 */
373 1.23694037861246766534e-07, /* 0x3e809a184368f145 */
374 8.23367955351123783984e-08, /* 0x3e761a2439b0d91c */
375 1.07591766213053694014e-07, /* 0x3e7ce1a65e39a978 */
376 1.42789947524631815640e-07, /* 0x3e832a39a93b6a66 */
377 1.32347123024711878538e-07, /* 0x3e81c3699af804e7 */
378 2.17626067316598149229e-08, /* 0x3e575e0f4e44ede8 */
379 2.34454866923044288656e-07, /* 0x3e8f77ced1a7a83b */
380 2.82966370261766916053e-09, /* 0x3e284e7f0cb1b500 */
381 2.29300919890907632975e-07, /* 0x3e8ec6b838b02dfe */
382 1.48428270450261284915e-07, /* 0x3e83ebf4dfbeda87 */
383 1.87937408574313982512e-07, /* 0x3e89397aed9cb475 */
384 6.13685946813334055347e-08, /* 0x3e707937bc239c54 */
385 1.98585022733583817493e-07, /* 0x3e8aa754553131b6 */
386 7.68394131623752961662e-08, /* 0x3e74a05d407c45dc */
387 1.28119052312436745644e-07, /* 0x3e8132231a206dd0 */
388 7.02119104719236502733e-08, /* 0x3e72d8ecfdd69c88 */
389 9.87954793820636301943e-08, /* 0x3e7a852c74218606 */
390 1.72176752381034986217e-07, /* 0x3e871bf2baeebb50 */
391 1.12877225146169704119e-08, /* 0x3e483d7db7491820 */
392 5.33549829555851737993e-08, /* 0x3e6ca50d92b6da14 */
393 2.13833275710816521345e-08, /* 0x3e56f5cde8530298 */
394 1.16243518048290556393e-07, /* 0x3e7f343198910740 */
395 6.29926408369055877943e-08, /* 0x3e70e8d241ccd80a */
396 6.45429039328021963791e-08, /* 0x3e71535ac619e6c8 */
397 8.64001922814281933403e-08, /* 0x3e77316041c36cd2 */
398 9.50767572202325800240e-08, /* 0x3e7985a000637d8e */
399 5.80851497508121135975e-08, /* 0x3e6f2f29858c0a68 */
400 1.82350561135024766232e-07, /* 0x3e8879847f96d909 */
401 1.98948680587390608655e-07, /* 0x3e8ab3d319e12e42 */
402 7.83548663450197659846e-08, /* 0x3e75088162dfc4c2 */
403 3.04374234486798594427e-08, /* 0x3e605749a1cd9d8c */
404 2.76135725629797411787e-08, /* 0x3e5da65c6c6b8618 */
405 4.32610105454203065470e-08, /* 0x3e6739bf7df1ad64 */
406 5.17107515324127256994e-08, /* 0x3e6bc31252aa3340 */
407 2.82398327875841444660e-08, /* 0x3e5e528191ad3aa8 */
408 1.87482469524195595399e-07, /* 0x3e8929d93df19f18 */
409 2.97481891662714096139e-08, /* 0x3e5ff11eb693a080 */
410 9.94421570843584316402e-09, /* 0x3e455ae3f145a3a0 */
411 1.07056210730391848428e-07, /* 0x3e7cbcd8c6c0ca82 */
412 6.25589580466881163081e-08, /* 0x3e70cb04d425d304 */
413 9.56641013869464593803e-08, /* 0x3e79adfcab5be678 */
414 1.88056307148355440276e-07, /* 0x3e893d90c5662508 */
415 8.38850689379557880950e-08, /* 0x3e768489bd35ff40 */
416 5.01215865527674122924e-09, /* 0x3e3586ed3da2b7e0 */
417 1.74166095998522089762e-07, /* 0x3e87604d2e850eee */
418 9.96779574395363585849e-08, /* 0x3e7ac1d12bfb53d8 */
419 5.98432026368321460686e-09, /* 0x3e39b3d468274740 */
420 1.18362922366887577169e-07, /* 0x3e7fc5d68d10e53c */
421 1.86086833284154215946e-07, /* 0x3e88f9e51884becb */
422 1.97671457251348941011e-07, /* 0x3e8a87f0869c06d1 */
423 1.42447160717199237159e-07, /* 0x3e831e7279f685fa */
424 1.05504240785546574184e-08, /* 0x3e46a8282f9719b0 */
425 3.13335218371639189324e-08, /* 0x3e60d2724a8a44e0 */
426 1.96518418901914535399e-07, /* 0x3e8a60524b11ad4e */
427 2.17692035039173536059e-08, /* 0x3e575fdf832750f0 */
428 2.15613114426529981675e-07, /* 0x3e8cf06902e4cd36 */
429 5.68271098300441214948e-08, /* 0x3e6e82422d4f6d10 */
430 1.70331455823369124256e-08, /* 0x3e524a091063e6c0 */
431 9.17590028095709583247e-08, /* 0x3e78a1a172dc6f38 */
432 2.77266304112916566247e-07, /* 0x3e929b6619f8a92d */
433 9.37041937614656939690e-08, /* 0x3e79274d9c1b70c8 */
434 1.56116346368316796511e-08, /* 0x3e50c34b1fbb7930 */
435 4.13967433808382727413e-08, /* 0x3e6639866c20eb50 */
436 1.70164749185821616276e-07, /* 0x3e86d6d0f6832e9e */
437 4.01708788545600086008e-07, /* 0x3e9af54def99f25e */
438 2.59663539226050551563e-07, /* 0x3e916cfc52a00262 */
439 2.22007487655027469542e-07, /* 0x3e8dcc1e83569c32 */
440 2.90542250809644081369e-07, /* 0x3e937f7a551ed425 */
441 4.67720537666628903341e-07, /* 0x3e9f6360adc98887 */
442 2.79799803956772554802e-07, /* 0x3e92c6ec8d35a2c1 */
443 2.07344552327432547723e-07, /* 0x3e8bd44df84cb036 */
444 2.54705698692735196368e-07, /* 0x3e9117cf826e310e */
445 4.26848589539548450728e-07, /* 0x3e9ca533f332cfc9 */
446 2.52506723633552216197e-07, /* 0x3e90f208509dbc2e */
447 2.14684129933849704964e-07, /* 0x3e8cd07d93c945de */
448 3.20134822201596505431e-07, /* 0x3e957bdfd67e6d72 */
449 9.93537565749855712134e-08, /* 0x3e7aab89c516c658 */
450 3.70792944827917252327e-08, /* 0x3e63e823b1a1b8a0 */
451 1.41772749369083698972e-07, /* 0x3e8307464a9d6d3c */
452 4.22446601490198804306e-07, /* 0x3e9c5993cd438843 */
453 4.11818433724801511540e-07, /* 0x3e9ba2fca02ab554 */
454 1.19976381502605310519e-07, /* 0x3e801a5b6983a268 */
455 3.43703078571520905265e-08, /* 0x3e6273d1b350efc8 */
456 1.66128705555453270379e-07, /* 0x3e864c238c37b0c6 */
457 5.00499610023283006540e-08, /* 0x3e6aded07370a300 */
458 1.75105139941208062123e-07, /* 0x3e878091197eb47e */
459 7.70807146729030327334e-08, /* 0x3e74b0f245e0dabc */
460 2.45918607526895836121e-07, /* 0x3e9080d9794e2eaf */
461 2.18359020958626199345e-07, /* 0x3e8d4ec242b60c76 */
462 8.44342887976445333569e-09, /* 0x3e4221d2f940caa0 */
463 1.07506148687888629299e-07, /* 0x3e7cdbc42b2bba5c */
464 5.36544954316820904572e-08, /* 0x3e6cce37bb440840 */
465 3.39109101518396596341e-07, /* 0x3e96c1d999cf1dd0 */
466 2.60098720293920613340e-08, /* 0x3e5bed8a07eb0870 */
467 8.42678991664621455827e-08, /* 0x3e769ed88f490e3c */
468 5.36972237470183633197e-08, /* 0x3e6cd41719b73ef0 */
469 4.28192558171921681288e-07, /* 0x3e9cbc4ac95b41b7 */
470 2.71535491483955143294e-07, /* 0x3e9238f1b890f5d7 */
471 7.84094998145075780203e-08, /* 0x3e750c4282259cc4 */
472 3.43880599134117431863e-07, /* 0x3e9713d2de87b3e2 */
473 1.32878065060366481043e-07, /* 0x3e81d5a7d2255276 */
474 4.18046802627967629428e-07, /* 0x3e9c0dfd48227ac1 */
475 2.65042411765766019424e-07, /* 0x3e91c964dab76753 */
476 1.70383695347518643694e-07, /* 0x3e86de56d5704496 */
477 1.54096497259613515678e-07, /* 0x3e84aeb71fd19968 */
478 2.36543402412459813461e-07, /* 0x3e8fbf91c57b1918 */
479 4.38416350106876736790e-07, /* 0x3e9d6bef7fbe5d9a */
480 3.03892161339927775731e-07, /* 0x3e9464d3dc249066 */
481 3.31136771605664899240e-07, /* 0x3e9638e2ec4d9073 */
482 6.49494294526590682218e-08, /* 0x3e716f4a7247ea7c */
483 4.10423429887181345747e-09, /* 0x3e31a0a740f1d440 */
484 1.70831640869113847224e-07, /* 0x3e86edbb0114a33c */
485 1.10811512657909180966e-07, /* 0x3e7dbee8bf1d513c */
486 3.23677724749783611964e-07, /* 0x3e95b8bdb0248f73 */
487 3.55662734259192678528e-07, /* 0x3e97de3d3f5eac64 */
488 2.30102333489738219140e-07, /* 0x3e8ee24187ae448a */
489 4.47429004000738629714e-07, /* 0x3e9e06c591ec5192 */
490 7.78167135617329598659e-08, /* 0x3e74e3861a332738 */
491 9.90345291908535415737e-08, /* 0x3e7a9599dcc2bfe4 */
492 5.85800913143113728314e-08, /* 0x3e6f732fbad43468 */
493 4.57859062410871843857e-07, /* 0x3e9eb9f573b727d9 */
494 3.67993069723390929794e-07, /* 0x3e98b212a2eb9897 */
495 2.90836464322977276043e-07, /* 0x3e9384884c167215 */
496 2.51621574250131388318e-07, /* 0x3e90e2d363020051 */
497 2.75789824740652815545e-07, /* 0x3e92820879fbd022 */
498 3.88985776250314403593e-07, /* 0x3e9a1ab9893e4b30 */
499 1.40214080183768019611e-07, /* 0x3e82d1b817a24478 */
500 3.23451432223550478373e-08, /* 0x3e615d7b8ded4878 */
501 9.15979180730608444470e-08, /* 0x3e78968f9db3a5e4 */
502 3.44371402498640470421e-07, /* 0x3e971c4171fe135f */
503 3.40401897215059498077e-07, /* 0x3e96d80f605d0d8c */
504 1.06431813453707950243e-07, /* 0x3e7c91f043691590 */
505 1.46204238932338846248e-07, /* 0x3e839f8a15fce2b2 */
506 9.94610376972039046878e-09, /* 0x3e455beda9d94b80 */
507 2.01711528092681771039e-07, /* 0x3e8b12c15d60949a */
508 2.72027977986191568296e-07, /* 0x3e924167b312bfe3 */
509 2.48402602511693757964e-07, /* 0x3e90ab8633070277 */
510 1.58480011219249621715e-07, /* 0x3e854554ebbc80ee */
511 3.00372828113368713281e-08, /* 0x3e60204aef5a4bb8 */
512 3.67816204583541976394e-07, /* 0x3e98af08c679cf2c */
513 2.46169793032343824291e-07, /* 0x3e90852a330ae6c8 */
514 1.70080468270204253247e-07, /* 0x3e86d3eb9ec32916 */
515 1.67806717763872914315e-07, /* 0x3e8685cb7fcbbafe */
516 2.67715622006907942620e-07, /* 0x3e91f751c1e0bd95 */
517 2.14411342550299170574e-08, /* 0x3e5705b1b0f72560 */
518 4.11228221283669073277e-07, /* 0x3e9b98d8d808ca92 */
519 3.52311752396749662260e-08, /* 0x3e62ea22c75cc980 */
520 3.52718000397367821054e-07, /* 0x3e97aba62bca0350 */
521 4.38857387992911129814e-07, /* 0x3e9d73833442278c */
522 3.22574606753482540743e-07, /* 0x3e95a5ca1fb18bf9 */
523 3.28730371182804296828e-08, /* 0x3e61a6092b6ecf28 */
524 7.56672470607639279700e-08, /* 0x3e744fd049aac104 */
525 3.26750155316369681821e-09, /* 0x3e2c114fd8df5180 */
526 3.21724445362095284743e-07, /* 0x3e95972f130feae5 */
527 1.06639427371776571151e-07, /* 0x3e7ca034a55fe198 */
528 3.41020788139524715063e-07, /* 0x3e96e2b149990227 */
529 1.00582838631232552824e-07, /* 0x3e7b00000294592c */
530 3.68439433859276640065e-07, /* 0x3e98b9bdc442620e */
531 2.20403078342388012027e-07, /* 0x3e8d94fdfabf3e4e */
532 1.62841467098298142534e-07, /* 0x3e85db30b145ad9a */
533 2.25325348296680733838e-07, /* 0x3e8e3e1eb95022b0 */
534 4.37462238226421614339e-07, /* 0x3e9d5b8b45442bd6 */
535 3.52055880555040706500e-07, /* 0x3e97a046231ecd2e */
536 4.75614398494781776825e-07, /* 0x3e9feafe3ef55232 */
537 3.60998399033215317516e-07, /* 0x3e9839e7bfd78267 */
538 3.79292434611513945954e-08, /* 0x3e645cf49d6fa900 */
539 1.29859015528549300061e-08, /* 0x3e4be3132b27f380 */
540 3.15927546985474913188e-07, /* 0x3e9533980bb84f9f */
541 2.28533679887379668031e-08, /* 0x3e5889e2ce3ba390 */
542 1.17222541823553133877e-07, /* 0x3e7f7778c3ad0cc8 */
543 1.51991208405464415857e-07, /* 0x3e846660cec4eba2 */
544 1.56958239325240655564e-07}; /* 0x3e85110b4611a626 */
545
546 /* Some constants and split constants. */
547
548 static double pi = 3.1415926535897932e+00, /* 0x400921fb54442d18 */
549 piby2 = 1.5707963267948966e+00, /* 0x3ff921fb54442d18 */
550 piby4 = 7.8539816339744831e-01, /* 0x3fe921fb54442d18 */
551 three_piby4 = 2.3561944901923449e+00, /* 0x4002d97c7f3321d2 */
552 pi_head = 3.1415926218032836e+00, /* 0x400921fb50000000 */
553 pi_tail = 3.1786509547056392e-08, /* 0x3e6110b4611a6263 */
554 piby2_head = 1.5707963267948965e+00, /* 0x3ff921fb54442d18 */
555 piby2_tail = 6.1232339957367660e-17; /* 0x3c91a62633145c07 */
556
557 double u, v, vbyu, q1, q2, s, u1, vu1, u2, vu2, uu, c, r;
558 unsigned int swap_vu, index, xzero, yzero, xnan, ynan, xinf, yinf;
559 int m, xexp, yexp, diffexp;
560
561 /* Find properties of arguments x and y. */
562
563 unsigned long long ux, ui, aux, xneg, uy, auy, yneg;
564
565 GET_BITS_DP64(x, ux);
566 GET_BITS_DP64(y, uy);
567 aux = ux & ~SIGNBIT_DP64;
568 auy = uy & ~SIGNBIT_DP64;
569 xexp = (int)((ux & EXPBITS_DP64) >> EXPSHIFTBITS_DP64);
570 yexp = (int)((uy & EXPBITS_DP64) >> EXPSHIFTBITS_DP64);
571 xneg = ux & SIGNBIT_DP64;
572 yneg = uy & SIGNBIT_DP64;
573 xzero = (aux == 0);
574 yzero = (auy == 0);
575 xnan = (aux > PINFBITPATT_DP64);
576 ynan = (auy > PINFBITPATT_DP64);
577 xinf = (aux == PINFBITPATT_DP64);
578 yinf = (auy == PINFBITPATT_DP64);
579
580 diffexp = yexp - xexp;
581
582 /* Special cases */
583
584 if (xnan)
585 return _handle_error("atan2", OP_ATAN2, ux|0x0008000000000000, _DOMAIN, 0,
586 EDOM, x, y, 2);
587 else if (ynan)
588 return _handle_error("atan2", OP_ATAN2, uy|0x0008000000000000, _DOMAIN, 0,
589 EDOM, x, y, 2);
590 else if (yzero)
591 { /* Zero y gives +-0 for positive x
592 and +-pi for negative x */
593 if (xneg)
594 {
595 if (yneg) return val_with_flags(-pi,AMD_F_INEXACT);
596 else return val_with_flags(pi,AMD_F_INEXACT);
597 }
598 else return y;
599 }
600 else if (xzero)
601 { /* Zero x gives +- pi/2
602 depending on sign of y */
603 if (yneg) return val_with_flags(-piby2,AMD_F_INEXACT);
604 else val_with_flags(piby2,AMD_F_INEXACT);
605 }
606
607 /* Scale up both x and y if they are both below 1/4.
608 This avoids any possible later denormalised arithmetic. */
609
610 if ((xexp < 1021 && yexp < 1021))
611 {
612 scaleUpDouble1024(ux, &ux);
613 scaleUpDouble1024(uy, &uy);
614 PUT_BITS_DP64(ux, x);
615 PUT_BITS_DP64(uy, y);
616 xexp = (int)((ux & EXPBITS_DP64) >> EXPSHIFTBITS_DP64);
617 yexp = (int)((uy & EXPBITS_DP64) >> EXPSHIFTBITS_DP64);
618 diffexp = yexp - xexp;
619 }
620
621 if (diffexp > 56)
622 { /* abs(y)/abs(x) > 2^56 => arctan(x/y)
623 is insignificant compared to piby2 */
624 if (yneg) return val_with_flags(-piby2,AMD_F_INEXACT);
625 else return val_with_flags(piby2,AMD_F_INEXACT);
626 }
627 else if (diffexp < -28 && (!xneg))
628 { /* x positive and dominant over y by a factor of 2^28.
629 In this case atan(y/x) is y/x to machine accuracy. */
630
631 if (diffexp < -1074) /* Result underflows */
632 {
633 if (yneg)
634 return val_with_flags(-0.0,AMD_F_INEXACT | AMD_F_UNDERFLOW);
635 else
636 return val_with_flags(0.0,AMD_F_INEXACT | AMD_F_UNDERFLOW);
637 }
638 else
639 {
640 if (diffexp < -1022)
641 {
642 /* Result will likely be denormalized */
643 y = scaleDouble_1(y, 100);
644 y /= x;
645 /* Now y is 2^100 times the true result. Scale it back down. */
646 GET_BITS_DP64(y, uy);
647 scaleDownDouble(uy, 100, &uy);
648 PUT_BITS_DP64(uy, y);
649 if ((uy & EXPBITS_DP64) == 0)
650 return val_with_flags(y, AMD_F_INEXACT | AMD_F_UNDERFLOW);
651 else
652 return y;
653 }
654 else
655 return y / x;
656 }
657 }
658 else if (diffexp < -56 && xneg)
659 { /* abs(x)/abs(y) > 2^56 and x < 0 => arctan(y/x)
660 is insignificant compared to pi */
661 if (yneg) return val_with_flags(-pi,AMD_F_INEXACT);
662 else return val_with_flags(pi,AMD_F_INEXACT);
663 }
664 else if (yinf && xinf)
665 { /* If abs(x) and abs(y) are both infinity
666 return +-pi/4 or +- 3pi/4 according to
667 signs. */
668 if (xneg)
669 {
670 if (yneg) return val_with_flags(-three_piby4,AMD_F_INEXACT);
671 else return val_with_flags(three_piby4,AMD_F_INEXACT);
672 }
673 else
674 {
675 if (yneg) return val_with_flags(-piby4,AMD_F_INEXACT);
676 else return val_with_flags(piby4,AMD_F_INEXACT);
677 }
678 }
679
680 /* General case: take absolute values of arguments */
681
682 u = x; v = y;
683 if (xneg) u = -x;
684 if (yneg) v = -y;
685
686 /* Swap u and v if necessary to obtain 0 < v < u. Compute v/u. */
687
688 swap_vu = (u < v);
689 if (swap_vu) { uu = u; u = v; v = uu; }
690 vbyu = v/u;
691
692 if (vbyu > 0.0625)
693 { /* General values of v/u. Use a look-up
694 table and series expansion. */
695
696 index = (int)(256*vbyu + 0.5);
697 q1 = atan_jby256_lead[index-16];
698 q2 = atan_jby256_tail[index-16];
699 c = index*1./256;
702 u = scaleDouble_2(u,-m);
703 v = scaleDouble_2(v,-m);
705 PUT_BITS_DP64(0xfffffffff8000000 & ui, u1); /* 26 leading bits of u */
706 u2 = u - u1;
707
708 r = ((v-c*u1)-c*u2)/(u+c*v);
709
710 /* Polynomial approximation to atan(r) */
711
712 s = r*r;
713 q2 = q2 + r - r*(s * (0.33333333333224095522 - s*(0.19999918038989143496)));
714 }
715 else if (vbyu < 1.e-8)
716 { /* v/u is small enough that atan(v/u) = v/u */
717 q1 = 0.0;
718 q2 = vbyu;
719 }
720 else /* vbyu <= 0.0625 */
721 {
722 /* Small values of v/u. Use a series expansion
723 computed carefully to minimise cancellation */
724
726 PUT_BITS_DP64(0xffffffff00000000 & ui, u1);
727 GET_BITS_DP64(vbyu, ui);
728 PUT_BITS_DP64(0xffffffff00000000 & ui, vu1);
729 u2 = u - u1;
730 vu2 = vbyu - vu1;
731
732 q1 = 0.0;
733 s = vbyu*vbyu;
734 q2 = vbyu +
735 ((((v - u1*vu1) - u2*vu1) - u*vu2)/u -
736 (vbyu*s*(0.33333333333333170500 -
737 s*(0.19999999999393223405 -
738 s*(0.14285713561807169030 -
739 s*(0.11110736283514525407 -
740 s*(0.90029810285449784439E-01)))))));
741 }
742
743 /* Tidy-up according to which quadrant the arguments lie in */
744
745 if (swap_vu) {q1 = piby2_head - q1; q2 = piby2_tail - q2;}
746 if (xneg) {q1 = pi_head - q1; q2 = pi_tail - q2;}
747 q1 = q1 + q2;
748
749 if (yneg) q1 = - q1;
750
751 return q1;
752}
#define index(s, c)
Definition: various.h:29
GLuint index
Definition: glext.h:6031
GLdouble GLdouble u2
Definition: glext.h:8308
GLdouble u1
Definition: glext.h:8308
const GLfloat * m
Definition: glext.h:10848
#define AMD_F_UNDERFLOW
Definition: libm_new.h:84
#define SIGNBIT_DP64
Definition: libm_util.h:44
#define EXPBITS_DP64
Definition: libm_util.h:45
#define EXPBIAS_DP64
Definition: libm_util.h:55
#define PUT_BITS_DP64(ux, x)
Definition: libm_util.h:124
UINT ui
Definition: oleauto.h:49

Referenced by __libm_sse2_atan2(), _CIatan2(), acos(), asin(), atan2f(), atan2l(), EMFDRV_ArcChordPie(), gdiplus_atan2(), GetDirection(), IntArc(), IntGdiWidenPath(), log10T(), logT(), Math_atan2(), PATH_Arc(), powT(), pres_atan2(), and ValarrayTest::transcendentals().

◆ atan2f()

_ACRTIMP float __cdecl atan2f ( float  fy,
float  fx 
)

Definition at line 51 of file atan2f.c.

52{
53 /* Array atan_jby256 contains precomputed values of atan(j/256),
54 for j = 16, 17, ..., 256. */
55
56 static const double atan_jby256[ 241] = {
57 6.24188099959573430842e-02, /* 0x3faff55bb72cfde9 */
58 6.63088949198234745008e-02, /* 0x3fb0f99ea71d52a6 */
59 7.01969710718705064423e-02, /* 0x3fb1f86dbf082d58 */
60 7.40829225490337306415e-02, /* 0x3fb2f719318a4a9a */
61 7.79666338315423007588e-02, /* 0x3fb3f59f0e7c559d */
62 8.18479898030765457007e-02, /* 0x3fb4f3fd677292fb */
63 8.57268757707448092464e-02, /* 0x3fb5f2324fd2d7b2 */
64 8.96031774848717321724e-02, /* 0x3fb6f03bdcea4b0c */
65 9.34767811585894559112e-02, /* 0x3fb7ee182602f10e */
66 9.73475734872236708739e-02, /* 0x3fb8ebc54478fb28 */
67 1.01215441667466668485e-01, /* 0x3fb9e94153cfdcf1 */
68 1.05080273416329528224e-01, /* 0x3fbae68a71c722b8 */
69 1.08941956989865793015e-01, /* 0x3fbbe39ebe6f07c3 */
70 1.12800381201659388752e-01, /* 0x3fbce07c5c3cca32 */
71 1.16655435441069349478e-01, /* 0x3fbddd21701eba6e */
72 1.20507009691224548087e-01, /* 0x3fbed98c2190043a */
73 1.24354994546761424279e-01, /* 0x3fbfd5ba9aac2f6d */
74 1.28199281231298117811e-01, /* 0x3fc068d584212b3d */
75 1.32039761614638734288e-01, /* 0x3fc0e6adccf40881 */
76 1.35876328229701304195e-01, /* 0x3fc1646541060850 */
77 1.39708874289163620386e-01, /* 0x3fc1e1fafb043726 */
78 1.43537293701821222491e-01, /* 0x3fc25f6e171a535c */
79 1.47361481088651630200e-01, /* 0x3fc2dcbdb2fba1ff */
80 1.51181331798580037562e-01, /* 0x3fc359e8edeb99a3 */
81 1.54996741923940972718e-01, /* 0x3fc3d6eee8c6626c */
82 1.58807608315631065832e-01, /* 0x3fc453cec6092a9e */
83 1.62613828597948567589e-01, /* 0x3fc4d087a9da4f17 */
84 1.66415301183114927586e-01, /* 0x3fc54d18ba11570a */
85 1.70211925285474380276e-01, /* 0x3fc5c9811e3ec269 */
86 1.74003600935367680469e-01, /* 0x3fc645bfffb3aa73 */
87 1.77790228992676047071e-01, /* 0x3fc6c1d4898933d8 */
88 1.81571711160032150945e-01, /* 0x3fc73dbde8a7d201 */
89 1.85347949995694760705e-01, /* 0x3fc7b97b4bce5b02 */
90 1.89118848926083965578e-01, /* 0x3fc8350be398ebc7 */
91 1.92884312257974643856e-01, /* 0x3fc8b06ee2879c28 */
92 1.96644245190344985064e-01, /* 0x3fc92ba37d050271 */
93 2.00398553825878511514e-01, /* 0x3fc9a6a8e96c8626 */
94 2.04147145182116990236e-01, /* 0x3fca217e601081a5 */
95 2.07889927202262986272e-01, /* 0x3fca9c231b403279 */
96 2.11626808765629753628e-01, /* 0x3fcb1696574d780b */
97 2.15357699697738047551e-01, /* 0x3fcb90d7529260a2 */
98 2.19082510780057748701e-01, /* 0x3fcc0ae54d768466 */
99 2.22801153759394493514e-01, /* 0x3fcc84bf8a742e6d */
100 2.26513541356919617664e-01, /* 0x3fccfe654e1d5395 */
101 2.30219587276843717927e-01, /* 0x3fcd77d5df205736 */
102 2.33919206214733416127e-01, /* 0x3fcdf110864c9d9d */
103 2.37612313865471241892e-01, /* 0x3fce6a148e96ec4d */
104 2.41298826930858800743e-01, /* 0x3fcee2e1451d980c */
105 2.44978663126864143473e-01, /* 0x3fcf5b75f92c80dd */
106 2.48651741190513253521e-01, /* 0x3fcfd3d1fc40dbe4 */
107 2.52317980886427151166e-01, /* 0x3fd025fa510665b5 */
108 2.55977303013005474952e-01, /* 0x3fd061eea03d6290 */
109 2.59629629408257511791e-01, /* 0x3fd09dc597d86362 */
110 2.63274882955282396590e-01, /* 0x3fd0d97ee509acb3 */
111 2.66912987587400396539e-01, /* 0x3fd1151a362431c9 */
112 2.70543868292936529052e-01, /* 0x3fd150973a9ce546 */
113 2.74167451119658789338e-01, /* 0x3fd18bf5a30bf178 */
114 2.77783663178873208022e-01, /* 0x3fd1c735212dd883 */
115 2.81392432649178403370e-01, /* 0x3fd2025567e47c95 */
116 2.84993688779881237938e-01, /* 0x3fd23d562b381041 */
117 2.88587361894077354396e-01, /* 0x3fd278372057ef45 */
118 2.92173383391398755471e-01, /* 0x3fd2b2f7fd9b5fe2 */
119 2.95751685750431536626e-01, /* 0x3fd2ed987a823cfe */
120 2.99322202530807379706e-01, /* 0x3fd328184fb58951 */
121 3.02884868374971361060e-01, /* 0x3fd362773707ebcb */
122 3.06439619009630070945e-01, /* 0x3fd39cb4eb76157b */
123 3.09986391246883430384e-01, /* 0x3fd3d6d129271134 */
124 3.13525122985043869228e-01, /* 0x3fd410cbad6c7d32 */
125 3.17055753209146973237e-01, /* 0x3fd44aa436c2af09 */
126 3.20578221991156986359e-01, /* 0x3fd4845a84d0c21b */
127 3.24092470489871664618e-01, /* 0x3fd4bdee586890e6 */
128 3.27598440950530811477e-01, /* 0x3fd4f75f73869978 */
129 3.31096076704132047386e-01, /* 0x3fd530ad9951cd49 */
130 3.34585322166458920545e-01, /* 0x3fd569d88e1b4cd7 */
131 3.38066122836825466713e-01, /* 0x3fd5a2e0175e0f4e */
132 3.41538425296541714449e-01, /* 0x3fd5dbc3fbbe768d */
133 3.45002177207105076295e-01, /* 0x3fd614840309cfe1 */
134 3.48457327308122011278e-01, /* 0x3fd64d1ff635c1c5 */
135 3.51903825414964732676e-01, /* 0x3fd685979f5fa6fd */
136 3.55341622416168290144e-01, /* 0x3fd6bdeac9cbd76c */
137 3.58770670270572189509e-01, /* 0x3fd6f61941e4def0 */
138 3.62190922004212156882e-01, /* 0x3fd72e22d53aa2a9 */
139 3.65602331706966821034e-01, /* 0x3fd7660752817501 */
140 3.69004854528964421068e-01, /* 0x3fd79dc6899118d1 */
141 3.72398446676754202311e-01, /* 0x3fd7d5604b63b3f7 */
142 3.75783065409248884237e-01, /* 0x3fd80cd46a14b1d0 */
143 3.79158669033441808605e-01, /* 0x3fd84422b8df95d7 */
144 3.82525216899905096124e-01, /* 0x3fd87b4b0c1ebedb */
145 3.85882669398073752109e-01, /* 0x3fd8b24d394a1b25 */
146 3.89230987951320717144e-01, /* 0x3fd8e92916f5cde8 */
147 3.92570135011828580396e-01, /* 0x3fd91fde7cd0c662 */
148 3.95900074055262896078e-01, /* 0x3fd9566d43a34907 */
149 3.99220769575252543149e-01, /* 0x3fd98cd5454d6b18 */
150 4.02532187077682512832e-01, /* 0x3fd9c3165cc58107 */
151 4.05834293074804064450e-01, /* 0x3fd9f93066168001 */
152 4.09127055079168300278e-01, /* 0x3fda2f233e5e530b */
153 4.12410441597387267265e-01, /* 0x3fda64eec3cc23fc */
154 4.15684422123729413467e-01, /* 0x3fda9a92d59e98cf */
155 4.18948967133552840902e-01, /* 0x3fdad00f5422058b */
156 4.22204048076583571270e-01, /* 0x3fdb056420ae9343 */
157 4.25449637370042266227e-01, /* 0x3fdb3a911da65c6c */
158 4.28685708391625730496e-01, /* 0x3fdb6f962e737efb */
159 4.31912235472348193799e-01, /* 0x3fdba473378624a5 */
160 4.35129193889246812521e-01, /* 0x3fdbd9281e528191 */
161 4.38336559857957774877e-01, /* 0x3fdc0db4c94ec9ef */
162 4.41534310525166673322e-01, /* 0x3fdc42191ff11eb6 */
163 4.44722423960939305942e-01, /* 0x3fdc76550aad71f8 */
164 4.47900879150937292206e-01, /* 0x3fdcaa6872f3631b */
165 4.51069655988523443568e-01, /* 0x3fdcde53432c1350 */
166 4.54228735266762495559e-01, /* 0x3fdd121566b7f2ad */
167 4.57378098670320809571e-01, /* 0x3fdd45aec9ec862b */
168 4.60517728767271039558e-01, /* 0x3fdd791f5a1226f4 */
169 4.63647609000806093515e-01, /* 0x3fddac670561bb4f */
170 4.66767723680866497560e-01, /* 0x3fdddf85bb026974 */
171 4.69878057975686880265e-01, /* 0x3fde127b6b0744af */
172 4.72978597903265574054e-01, /* 0x3fde4548066cf51a */
173 4.76069330322761219421e-01, /* 0x3fde77eb7f175a34 */
174 4.79150242925822533735e-01, /* 0x3fdeaa65c7cf28c4 */
175 4.82221324227853687105e-01, /* 0x3fdedcb6d43f8434 */
176 4.85282563559221225002e-01, /* 0x3fdf0ede98f393cf */
177 4.88333951056405479729e-01, /* 0x3fdf40dd0b541417 */
178 4.91375477653101910835e-01, /* 0x3fdf72b221a4e495 */
179 4.94407135071275316562e-01, /* 0x3fdfa45dd3029258 */
180 4.97428915812172245392e-01, /* 0x3fdfd5e0175fdf83 */
181 5.00440813147294050189e-01, /* 0x3fe0039c73c1a40b */
182 5.03442821109336358099e-01, /* 0x3fe01c341e82422d */
183 5.06434934483096732549e-01, /* 0x3fe034b709250488 */
184 5.09417148796356245022e-01, /* 0x3fe04d25314342e5 */
185 5.12389460310737621107e-01, /* 0x3fe0657e94db30cf */
186 5.15351866012543347040e-01, /* 0x3fe07dc3324e9b38 */
187 5.18304363603577900044e-01, /* 0x3fe095f30861a58f */
188 5.21246951491958210312e-01, /* 0x3fe0ae0e1639866c */
189 5.24179628782913242802e-01, /* 0x3fe0c6145b5b43da */
190 5.27102395269579471204e-01, /* 0x3fe0de05d7aa6f7c */
191 5.30015251423793132268e-01, /* 0x3fe0f5e28b67e295 */
192 5.32918198386882147055e-01, /* 0x3fe10daa77307a0d */
193 5.35811237960463593311e-01, /* 0x3fe1255d9bfbd2a8 */
194 5.38694372597246617929e-01, /* 0x3fe13cfbfb1b056e */
195 5.41567605391844897333e-01, /* 0x3fe1548596376469 */
196 5.44430940071603086672e-01, /* 0x3fe16bfa6f5137e1 */
197 5.47284380987436924748e-01, /* 0x3fe1835a88be7c13 */
198 5.50127933104692989907e-01, /* 0x3fe19aa5e5299f99 */
199 5.52961601994028217888e-01, /* 0x3fe1b1dc87904284 */
200 5.55785393822313511514e-01, /* 0x3fe1c8fe7341f64f */
201 5.58599315343562330405e-01, /* 0x3fe1e00babdefeb3 */
202 5.61403373889889367732e-01, /* 0x3fe1f7043557138a */
203 5.64197577362497537656e-01, /* 0x3fe20de813e823b1 */
204 5.66981934222700489912e-01, /* 0x3fe224b74c1d192a */
205 5.69756453482978431069e-01, /* 0x3fe23b71e2cc9e6a */
206 5.72521144698072359525e-01, /* 0x3fe25217dd17e501 */
207 5.75276017956117824426e-01, /* 0x3fe268a940696da6 */
208 5.78021083869819540801e-01, /* 0x3fe27f261273d1b3 */
209 5.80756353567670302596e-01, /* 0x3fe2958e59308e30 */
210 5.83481838685214859730e-01, /* 0x3fe2abe21aded073 */
211 5.86197551356360535557e-01, /* 0x3fe2c2215e024465 */
212 5.88903504204738026395e-01, /* 0x3fe2d84c2961e48b */
213 5.91599710335111383941e-01, /* 0x3fe2ee628406cbca */
214 5.94286183324841177367e-01, /* 0x3fe30464753b090a */
215 5.96962937215401501234e-01, /* 0x3fe31a52048874be */
216 5.99629986503951384336e-01, /* 0x3fe3302b39b78856 */
217 6.02287346134964152178e-01, /* 0x3fe345f01cce37bb */
218 6.04935031491913965951e-01, /* 0x3fe35ba0b60eccce */
219 6.07573058389022313541e-01, /* 0x3fe3713d0df6c503 */
220 6.10201443063065118722e-01, /* 0x3fe386c52d3db11e */
221 6.12820202165241245673e-01, /* 0x3fe39c391cd41719 */
222 6.15429352753104952356e-01, /* 0x3fe3b198e5e2564a */
223 6.18028912282561737612e-01, /* 0x3fe3c6e491c78dc4 */
224 6.20618898599929469384e-01, /* 0x3fe3dc1c2a188504 */
225 6.23199329934065904268e-01, /* 0x3fe3f13fb89e96f4 */
226 6.25770224888563042498e-01, /* 0x3fe4064f47569f48 */
227 6.28331602434009650615e-01, /* 0x3fe41b4ae06fea41 */
228 6.30883481900321840818e-01, /* 0x3fe430328e4b26d5 */
229 6.33425882969144482537e-01, /* 0x3fe445065b795b55 */
230 6.35958825666321447834e-01, /* 0x3fe459c652badc7f */
231 6.38482330354437466191e-01, /* 0x3fe46e727efe4715 */
232 6.40996417725432032775e-01, /* 0x3fe4830aeb5f7bfd */
233 6.43501108793284370968e-01, /* 0x3fe4978fa3269ee1 */
234 6.45996424886771558604e-01, /* 0x3fe4ac00b1c71762 */
235 6.48482387642300484032e-01, /* 0x3fe4c05e22de94e4 */
236 6.50959018996812410762e-01, /* 0x3fe4d4a8023414e8 */
237 6.53426341180761927063e-01, /* 0x3fe4e8de5bb6ec04 */
238 6.55884376711170835605e-01, /* 0x3fe4fd013b7dd17e */
239 6.58333148384755983962e-01, /* 0x3fe51110adc5ed81 */
240 6.60772679271132590273e-01, /* 0x3fe5250cbef1e9fa */
241 6.63202992706093175102e-01, /* 0x3fe538f57b89061e */
242 6.65624112284960989250e-01, /* 0x3fe54ccaf0362c8f */
243 6.68036061856020157990e-01, /* 0x3fe5608d29c70c34 */
244 6.70438865514021320458e-01, /* 0x3fe5743c352b33b9 */
245 6.72832547593763097282e-01, /* 0x3fe587d81f732fba */
246 6.75217132663749830535e-01, /* 0x3fe59b60f5cfab9d */
247 6.77592645519925151909e-01, /* 0x3fe5aed6c5909517 */
248 6.79959111179481823228e-01, /* 0x3fe5c2399c244260 */
249 6.82316554874748071313e-01, /* 0x3fe5d58987169b18 */
250 6.84665002047148862907e-01, /* 0x3fe5e8c6941043cf */
251 6.87004478341244895212e-01, /* 0x3fe5fbf0d0d5cc49 */
252 6.89335009598845749323e-01, /* 0x3fe60f084b46e05e */
253 6.91656621853199760075e-01, /* 0x3fe6220d115d7b8d */
254 6.93969341323259825138e-01, /* 0x3fe634ff312d1f3b */
255 6.96273194408023488045e-01, /* 0x3fe647deb8e20b8f */
256 6.98568207680949848637e-01, /* 0x3fe65aabb6c07b02 */
257 7.00854407884450081312e-01, /* 0x3fe66d663923e086 */
258 7.03131821924453670469e-01, /* 0x3fe6800e4e7e2857 */
259 7.05400476865049030906e-01, /* 0x3fe692a40556fb6a */
260 7.07660399923197958039e-01, /* 0x3fe6a5276c4b0575 */
261 7.09911618463524796141e-01, /* 0x3fe6b798920b3d98 */
262 7.12154159993178659249e-01, /* 0x3fe6c9f7855c3198 */
263 7.14388052156768926793e-01, /* 0x3fe6dc44551553ae */
264 7.16613322731374569052e-01, /* 0x3fe6ee7f10204aef */
265 7.18829999621624415873e-01, /* 0x3fe700a7c5784633 */
266 7.21038110854851588272e-01, /* 0x3fe712be84295198 */
267 7.23237684576317874097e-01, /* 0x3fe724c35b4fae7b */
268 7.25428749044510712274e-01, /* 0x3fe736b65a172dff */
269 7.27611332626510676214e-01, /* 0x3fe748978fba8e0f */
270 7.29785463793429123314e-01, /* 0x3fe75a670b82d8d8 */
271 7.31951171115916565668e-01, /* 0x3fe76c24dcc6c6c0 */
272 7.34108483259739652560e-01, /* 0x3fe77dd112ea22c7 */
273 7.36257428981428097003e-01, /* 0x3fe78f6bbd5d315e */
274 7.38398037123989547936e-01, /* 0x3fe7a0f4eb9c19a2 */
275 7.40530336612692630105e-01, /* 0x3fe7b26cad2e50fd */
276 7.42654356450917929600e-01, /* 0x3fe7c3d311a6092b */
277 7.44770125716075148681e-01, /* 0x3fe7d528289fa093 */
278 7.46877673555587429099e-01, /* 0x3fe7e66c01c114fd */
279 7.48977029182941400620e-01, /* 0x3fe7f79eacb97898 */
280 7.51068221873802288613e-01, /* 0x3fe808c03940694a */
281 7.53151280962194302759e-01, /* 0x3fe819d0b7158a4c */
282 7.55226235836744863583e-01, /* 0x3fe82ad036000005 */
283 7.57293115936992444759e-01, /* 0x3fe83bbec5cdee22 */
284 7.59351950749757920178e-01, /* 0x3fe84c9c7653f7ea */
285 7.61402769805578416573e-01, /* 0x3fe85d69576cc2c5 */
286 7.63445602675201784315e-01, /* 0x3fe86e2578f87ae5 */
287 7.65480478966144461950e-01, /* 0x3fe87ed0eadc5a2a */
288 7.67507428319308182552e-01, /* 0x3fe88f6bbd023118 */
289 7.69526480405658186434e-01, /* 0x3fe89ff5ff57f1f7 */
290 7.71537664922959498526e-01, /* 0x3fe8b06fc1cf3dfe */
291 7.73541011592573490852e-01, /* 0x3fe8c0d9145cf49d */
292 7.75536550156311621507e-01, /* 0x3fe8d13206f8c4ca */
293 7.77524310373347682379e-01, /* 0x3fe8e17aa99cc05d */
294 7.79504322017186335181e-01, /* 0x3fe8f1b30c44f167 */
295 7.81476614872688268854e-01, /* 0x3fe901db3eeef187 */
296 7.83441218733151756304e-01, /* 0x3fe911f35199833b */
297 7.85398163397448278999e-01}; /* 0x3fe921fb54442d18 */
298
299 /* Some constants. */
300
301 static double pi = 3.1415926535897932e+00, /* 0x400921fb54442d18 */
302 piby2 = 1.5707963267948966e+00, /* 0x3ff921fb54442d18 */
303 piby4 = 7.8539816339744831e-01, /* 0x3fe921fb54442d18 */
304 three_piby4 = 2.3561944901923449e+00; /* 0x4002d97c7f3321d2 */
305
306 double u, v, vbyu, q, s, uu, r;
307 unsigned int swap_vu, index, xzero, yzero, xnan, ynan, xinf, yinf;
308 int xexp, yexp, diffexp;
309
310 double x = fx;
311 double y = fy;
312
313 /* Find properties of arguments x and y. */
314
315 unsigned long long ux, aux, xneg, uy, auy, yneg;
316
317 GET_BITS_DP64(x, ux);
318 GET_BITS_DP64(y, uy);
319 aux = ux & ~SIGNBIT_DP64;
320 auy = uy & ~SIGNBIT_DP64;
321 xexp = (int)((ux & EXPBITS_DP64) >> EXPSHIFTBITS_DP64);
322 yexp = (int)((uy & EXPBITS_DP64) >> EXPSHIFTBITS_DP64);
323 xneg = ux & SIGNBIT_DP64;
324 yneg = uy & SIGNBIT_DP64;
325 xzero = (aux == 0);
326 yzero = (auy == 0);
327 xnan = (aux > PINFBITPATT_DP64);
328 ynan = (auy > PINFBITPATT_DP64);
329 xinf = (aux == PINFBITPATT_DP64);
330 yinf = (auy == PINFBITPATT_DP64);
331
332 diffexp = yexp - xexp;
333
334 /* Special cases */
335
336 if (xnan)
337 {
338 unsigned int ufx;
339 GET_BITS_SP32(fx, ufx);
340 return _handle_errorf("atan2f", OP_ATAN2, ufx|0x00400000, _DOMAIN, 0,
341 EDOM, fx, fy, 2);
342 }
343 else if (ynan)
344 {
345 unsigned int ufy;
346 GET_BITS_SP32(fy, ufy);
347 return _handle_errorf("atan2f", OP_ATAN2, ufy|0x00400000, _DOMAIN, 0,
348 EDOM, fx, fy, 2);
349 }
350 else if (yzero)
351 { /* Zero y gives +-0 for positive x
352 and +-pi for negative x */
353 if (xneg)
354 {
355 if (yneg) return valf_with_flags((float)-pi, AMD_F_INEXACT);
356 else return valf_with_flags((float)pi, AMD_F_INEXACT);
357 }
358 else return (float)y;
359 }
360 else if (xzero)
361 { /* Zero x gives +- pi/2
362 depending on sign of y */
363 if (yneg) return valf_with_flags((float)-piby2, AMD_F_INEXACT);
364 else valf_with_flags((float)piby2, AMD_F_INEXACT);
365 }
366
367 if (diffexp > 26)
368 { /* abs(y)/abs(x) > 2^26 => arctan(x/y)
369 is insignificant compared to piby2 */
370 if (yneg) return valf_with_flags((float)-piby2, AMD_F_INEXACT);
371 else return valf_with_flags((float)piby2, AMD_F_INEXACT);
372 }
373 else if (diffexp < -13 && (!xneg))
374 { /* x positive and dominant over y by a factor of 2^13.
375 In this case atan(y/x) is y/x to machine accuracy. */
376
377 if (diffexp < -150) /* Result underflows */
378 {
379 if (yneg)
380 return valf_with_flags(-0.0F, AMD_F_INEXACT | AMD_F_UNDERFLOW);
381 else
382 return valf_with_flags(0.0F, AMD_F_INEXACT | AMD_F_UNDERFLOW);
383 }
384 else
385 {
386 if (diffexp < -126)
387 {
388 /* Result will likely be denormalized */
389 y = scaleDouble_1(y, 100);
390 y /= x;
391 /* Now y is 2^100 times the true result. Scale it back down. */
392 GET_BITS_DP64(y, uy);
393 scaleDownDouble(uy, 100, &uy);
394 PUT_BITS_DP64(uy, y);
395 if ((uy & EXPBITS_DP64) == 0)
396 return valf_with_flags((float)y, AMD_F_INEXACT | AMD_F_UNDERFLOW);
397 else
398 return (float)y;
399 }
400 else
401 return (float)(y / x);
402 }
403 }
404 else if (diffexp < -26 && xneg)
405 { /* abs(x)/abs(y) > 2^56 and x < 0 => arctan(y/x)
406 is insignificant compared to pi */
407 if (yneg) return valf_with_flags((float)-pi, AMD_F_INEXACT);
408 else return valf_with_flags((float)pi, AMD_F_INEXACT);
409 }
410 else if (yinf && xinf)
411 { /* If abs(x) and abs(y) are both infinity
412 return +-pi/4 or +- 3pi/4 according to
413 signs. */
414 if (xneg)
415 {
416 if (yneg) return valf_with_flags((float)-three_piby4, AMD_F_INEXACT);
417 else return valf_with_flags((float)three_piby4, AMD_F_INEXACT);
418 }
419 else
420 {
421 if (yneg) return valf_with_flags((float)-piby4, AMD_F_INEXACT);
422 else return valf_with_flags((float)piby4, AMD_F_INEXACT);
423 }
424 }
425
426 /* General case: take absolute values of arguments */
427
428 u = x; v = y;
429 if (xneg) u = -x;
430 if (yneg) v = -y;
431
432 /* Swap u and v if necessary to obtain 0 < v < u. Compute v/u. */
433
434 swap_vu = (u < v);
435 if (swap_vu) { uu = u; u = v; v = uu; }
436 vbyu = v/u;
437
438 if (vbyu > 0.0625)
439 { /* General values of v/u. Use a look-up
440 table and series expansion. */
441
442 index = (int)(256*vbyu + 0.5);
443 r = (256*v-index*u)/(256*u+index*v);
444
445 /* Polynomial approximation to atan(vbyu) */
446
447 s = r*r;
448 q = atan_jby256[index-16] + r - r*s*0.33333333333224095522;
449 }
450 else if (vbyu < 1.e-4)
451 { /* v/u is small enough that atan(v/u) = v/u */
452 q = vbyu;
453 }
454 else /* vbyu <= 0.0625 */
455 {
456 /* Small values of v/u. Use a series expansion */
457
458 s = vbyu*vbyu;
459 q = vbyu -
460 vbyu*s*(0.33333333333333170500 -
461 s*(0.19999999999393223405 -
462 s*0.14285713561807169030));
463 }
464
465 /* Tidy-up according to which quadrant the arguments lie in */
466
467 if (swap_vu) {q = piby2 - q;}
468 if (xneg) {q = pi - q;}
469 if (yneg) q = - q;
470 return (float)q;
471}
GLfixed fx
Definition: tritemp.h:484
GLfixed fy
Definition: tritemp.h:490

Referenced by D3DXSHRotate().

◆ atan2l()

static long double atan2l ( long double  x,
long double  y 
)
inlinestatic

Definition at line 429 of file math.h.

429{ return atan2( (double)y, (double)x ); }

◆ atanf()

_ACRTIMP float __cdecl atanf ( float  fx)

Definition at line 47 of file atanf.c.

48{
49
50 /* Some constants and split constants. */
51
52 static double piby2 = 1.5707963267948966e+00; /* 0x3ff921fb54442d18 */
53
54 double c, v, s, q, z;
55 unsigned int xnan;
56
57 double x = fx;
58
59 /* Find properties of argument fx. */
60
61 unsigned long long ux, aux, xneg;
62
63 GET_BITS_DP64(x, ux);
64 aux = ux & ~SIGNBIT_DP64;
65 xneg = ux & SIGNBIT_DP64;
66
67 v = x;
68 if (xneg) v = -x;
69
70 /* Argument reduction to range [-7/16,7/16] */
71
72 if (aux < 0x3fdc000000000000) /* v < 7./16. */
73 {
74 x = v;
75 c = 0.0;
76 }
77 else if (aux < 0x3fe6000000000000) /* v < 11./16. */
78 {
79 x = (2.0*v-1.0)/(2.0+v);
80 /* c = arctan(0.5) */
81 c = 4.63647609000806093515e-01; /* 0x3fddac670561bb4f */
82 }
83 else if (aux < 0x3ff3000000000000) /* v < 19./16. */
84 {
85 x = (v-1.0)/(1.0+v);
86 /* c = arctan(1.) */
87 c = 7.85398163397448278999e-01; /* 0x3fe921fb54442d18 */
88 }
89 else if (aux < 0x4003800000000000) /* v < 39./16. */
90 {
91 x = (v-1.5)/(1.0+1.5*v);
92 /* c = arctan(1.5) */
93 c = 9.82793723247329054082e-01; /* 0x3fef730bd281f69b */
94 }
95 else
96 {
97
98 xnan = (aux > PINFBITPATT_DP64);
99
100 if (xnan)
101 {
102 /* x is NaN */
103 unsigned int uhx;
104 GET_BITS_SP32(fx, uhx);
105 return _handle_errorf("atanf", OP_ATAN, uhx|0x00400000, _DOMAIN,
106 0, EDOM, fx, 0.0F, 1);
107 }
108 else if (v > 0x4c80000000000000)
109 { /* abs(x) > 2^26 => arctan(1/x) is
110 insignificant compared to piby2 */
111 if (xneg)
112 return valf_with_flags((float)-piby2, AMD_F_INEXACT);
113 else
114 return valf_with_flags((float)piby2, AMD_F_INEXACT);
115 }
116
117 x = -1.0/v;
118 /* c = arctan(infinity) */
119 c = 1.57079632679489655800e+00; /* 0x3ff921fb54442d18 */
120 }
121
122 /* Core approximation: Remez(2,2) on [-7/16,7/16] */
123
124 s = x*x;
125 q = x*s*
126 (0.296528598819239217902158651186e0 +
127 (0.192324546402108583211697690500e0 +
128 0.470677934286149214138357545549e-2*s)*s)/
129 (0.889585796862432286486651434570e0 +
130 (0.111072499995399550138837673349e1 +
131 0.299309699959659728404442796915e0*s)*s);
132
133 z = c - (q - x);
134
135 if (xneg) z = -z;
136 return (float)z;
137}

Referenced by MSVCRT_atanf(), Test_atanf_approx(), and Test_atanf_exact().

◆ atanh()

_ACRTIMP double __cdecl atanh ( double  x)

Definition at line 63 of file fun_ieee.c.

64{
65 // must be x>-1, x<1, if not return Nan (Not a Number)
66 if(!(x>-1.0 && x<1.0)) return sqrt(-1.0);
67
68 return log((1.0+x)/(1.0-x))/2.0;
69}

◆ atanhf()

_ACRTIMP float __cdecl atanhf ( float  )

◆ cbrt()

Referenced by rpn_cbrt().

◆ cbrtf()

_ACRTIMP float __cdecl cbrtf ( float  )

◆ ceil()

Definition at line 18 of file ceil.c.

19{
20 /* Load the value as uint64 */
21 unsigned long long u64 = *(unsigned long long*)&x;
22
23 /* Check for NAN */
24 if ((u64 & ~(1ULL << 63)) > 0x7FF0000000000000ull)
25 {
26 /* Set error bit */
27 u64 |= 0x0008000000000000ull;
28 return *(double*)&u64;
29 }
30
31 /* Check if x is positive */
32 if ((u64 & (1ULL << 63)) == 0)
33 {
34 /* Check if it fits into an int64 */
35 if (x < (double)_I64_MAX)
36 {
37 /* Cast to int64 to truncate towards 0. If this matches the
38 input, return it as is, otherwise add 1 */
39 double y = (double)(long long)x;
40 return (x > y) ? y + 1 : y;
41 }
42 else
43 {
44 /* The exponent is larger than the fraction bits.
45 This means the number is already an integer. */
46 return x;
47 }
48 }
49 else
50 {
51 /* Check if it fits into an int64 */
52 if (x > (double)_I64_MIN)
53 {
54 /* Cast to int64 to truncate towards 0. */
55 x = (double)(long long)x;
56 return (x == 0.) ? -0.0 : x;
57 }
58 else
59 {
60 /* The exponent is larger than the fraction bits.
61 This means the number is already an integer. */
62 return x;
63 }
64 }
65}
ULONG64 u64
Definition: btrfs.h:15
#define _I64_MAX
Definition: limits.h:37
#define _I64_MIN
Definition: limits.h:38
static const char mbstate_t *static wchar_t const char mbstate_t *static const wchar_t int *static double
Definition: string.c:91

Referenced by brush_fill_pixels(), ceilf(), ceill(), convert_to_fos_high_precision(), findRightGridIndices(), IntDrawArc(), IntFillArc(), Math_ceil(), PATH_Arc(), round(), rpn_dec2dms(), Test_ceil(), VarBstrFromDate(), VarFix(), VarR8Round(), VarRound(), and VarUdateFromDate().

◆ ceilf()

_ACRTIMP float __cdecl ceilf ( float  x)

Definition at line 40 of file ceilf.c.

41{
42 float r;
43 int rexp, xneg;
44 unsigned int ux, ax, ur, mask;
45
46 GET_BITS_SP32(x, ux);
47 ax = ux & (~SIGNBIT_SP32);
48 xneg = (ux != ax);
49
50 if (ax >= 0x4b800000)
51 {
52 /* abs(x) is either NaN, infinity, or >= 2^24 */
53 if (ax > 0x7f800000)
54 /* x is NaN */
55 return _handle_errorf("ceilf", OP_CEIL, ux, _DOMAIN, 0, EDOM, x,
56 0.0F, 1);
57 else
58 return x;
59 }
60 else if (ax < 0x3f800000) /* abs(x) < 1.0 */
61 {
62 if (ax == 0x00000000)
63 /* x is +zero or -zero; return the same zero */
64 return x;
65 else if (xneg) /* x < 0.0 */
66 {
67 PUT_BITS_SP32(SIGNBIT_SP32, r); /* return -0.0 */
68 return r;
69 }
70 else
71 return 1.0F;
72 }
73 else
74 {
75 rexp = ((ux & EXPBITS_SP32) >> EXPSHIFTBITS_SP32) - EXPBIAS_SP32;
76 /* Mask out the bits of r that we don't want */
77 mask = (1 << (EXPSHIFTBITS_SP32 - rexp)) - 1;
78 ur = (ux & ~mask);
79 PUT_BITS_SP32(ur, r);
80
81 if (xneg || (ux == ur)) return r;
82 else
83 /* We threw some bits away and x was positive */
84 return r + 1.0F;
85 }
86}
GLenum GLint GLuint mask
Definition: glext.h:6028
ecx edi movl ebx edx edi decl ecx esi eax jecxz decl eax andl eax esi movl edx movl TEMP incl eax andl eax ecx incl ebx testl eax jnz xchgl ecx incl TEMP esp ecx subl ebx pushl ecx ecx edx ecx shrl ecx mm0 mm4 mm0 mm4 mm1 mm5 mm1 mm5 mm2 mm6 mm2 mm6 mm3 mm7 mm3 mm7 paddd mm0 paddd mm4 paddd mm0 paddd mm4 paddd mm0 paddd mm4 movq mm1 movq mm5 psrlq mm1 psrlq mm5 paddd mm0 paddd mm4 psrad mm0 psrad mm4 packssdw mm0 packssdw mm4 mm1 punpckldq mm0 pand mm1 pand mm0 por mm1 movq edi esi edx edi decl ecx jnz popl ecx andl ecx jecxz mm0 mm0 mm1 mm1 mm2 mm2 mm3 mm3 paddd mm0 paddd mm0 paddd mm0 movq mm1 psrlq mm1 paddd mm0 psrad mm0 packssdw mm0 movd eax movw ax
Definition: synth_sse3d.h:180

◆ cos()

Definition at line 21 of file cos.c.

22{
23 int quadrant;
24 double x2, result;
25
26 /* Calculate the quadrant */
27 quadrant = (int)(x * (2./M_PI));
28
29 /* Get offset inside quadrant */
30 x = x - quadrant * (M_PI/2.);
31
32 /* Normalize quadrant to [0..3] */
33 quadrant = quadrant & 0x3;
34
35 /* Fixup value for the generic function */
36 x += cos_off_tbl[quadrant];
37
38 /* Calculate the negative of the square of x */
39 x2 = - (x * x);
40
41 /* This is an unrolled taylor series using <PRECISION> iterations
42 * Example with 4 iterations:
43 * result = 1 - x^2/2! + x^4/4! - x^6/6! + x^8/8!
44 * To save multiplications and to keep the precision high, it's performed
45 * like this:
46 * result = 1 - x^2 * (1/2! - x^2 * (1/4! - x^2 * (1/6! - x^2 * (1/8!))))
47 */
48
49 /* Start with 0, compiler will optimize this away */
50 result = 0;
51
52#if (PRECISION >= 10)
53 result += 1./(1.*2*3*4*5*6*7*8*9*10*11*12*13*14*15*16*17*18*19*20);
54 result *= x2;
55#endif
56#if (PRECISION >= 9)
57 result += 1./(1.*2*3*4*5*6*7*8*9*10*11*12*13*14*15*16*17*18);
58 result *= x2;
59#endif
60#if (PRECISION >= 8)
61 result += 1./(1.*2*3*4*5*6*7*8*9*10*11*12*13*14*15*16);
62 result *= x2;
63#endif
64#if (PRECISION >= 7)
65 result += 1./(1.*2*3*4*5*6*7*8*9*10*11*12*13*14);
66 result *= x2;
67#endif
68#if (PRECISION >= 6)
69 result += 1./(1.*2*3*4*5*6*7*8*9*10*11*12);
70 result *= x2;
71#endif
72#if (PRECISION >= 5)
73 result += 1./(1.*2*3*4*5*6*7*8*9*10);
74 result *= x2;
75#endif
76 result += 1./(1.*2*3*4*5*6*7*8);
77 result *= x2;
78
79 result += 1./(1.*2*3*4*5*6);
80 result *= x2;
81
82 result += 1./(1.*2*3*4);
83 result *= x2;
84
85 result += 1./(1.*2);
86 result *= x2;
87
88 result += 1;
89
90 /* Apply correct sign */
91 result *= cos_sign_tbl[quadrant];
92
93 return result;
94}
static double cos_off_tbl[]
Definition: cos.c:17
static double cos_sign_tbl[]
Definition: cos.c:18
#define M_PI
Definition: cos.c:15

Referenced by __cos(), __libm_sse2_cos(), __libm_sse2_cosf(), __sincos(), _CIcos(), _libm_sse2_cos_precise(), add_arc_part(), AngleBetweenVectorsRad(), attempt_line_merge(), compute_sincos_table(), cosf(), cosl(), create_outline(), D3DRMQuaternionFromRotation(), D3DRMVectorRotate(), draw_cap(), draw_graphics(), DrawGLScene(), EMFDRV_ArcChordPie(), expT(), GdipRotateMatrix(), generateTestSignal(), gl_Lightfv(), gl_rotation_matrix(), Global_Cos(), init_layer3(), IntGdiAngleArc(), IntGdiWidenPath(), Math_cos(), CDrvDefExt::PaintStaticControls(), PATH_DoArcPart(), polar(), powT(), prepare_decode_tables(), pres_cos(), render(), RotatePoint(), rpn_cos(), shorten_line_percent(), sincos(), Test_cos_approx(), Test_cos_exact(), ValarrayTest::transcendentals(), and unstretch_angle().

◆ cosf()

◆ cosh()

Definition at line 11 of file cosh.c.

12{
13 const double ebig = exp(fabs(x));
14 return (ebig + 1.0/ebig) / 2.0;
15}
DWORD exp
Definition: msg.c:16058

Referenced by _CIcosh(), coshf(), coshl(), rpn_cosh(), test_math_functions(), and ValarrayTest::transcendentals().

◆ coshf()

_ACRTIMP float __cdecl coshf ( float  fx)

Definition at line 51 of file coshf.c.

52{
53 /*
54 After dealing with special cases the computation is split into
55 regions as follows:
56
57 abs(x) >= max_cosh_arg:
58 cosh(x) = sign(x)*Inf
59
60 abs(x) >= small_threshold:
61 cosh(x) = sign(x)*exp(abs(x))/2 computed using the
62 splitexp and scaleDouble functions as for exp_amd().
63
64 abs(x) < small_threshold:
65 compute p = exp(y) - 1 and then z = 0.5*(p+(p/(p+1.0)))
66 cosh(x) is then sign(x)*z. */
67
68 static const double
69 /* The max argument of coshf, but stored as a double */
70 max_cosh_arg = 8.94159862922329438106e+01, /* 0x40565a9f84f82e63 */
71 thirtytwo_by_log2 = 4.61662413084468283841e+01, /* 0x40471547652b82fe */
72 log2_by_32_lead = 2.16608493356034159660e-02, /* 0x3f962e42fe000000 */
73 log2_by_32_tail = 5.68948749532545630390e-11, /* 0x3dcf473de6af278e */
74
75 small_threshold = 8*BASEDIGITS_DP64*0.30102999566398119521373889;
76// small_threshold = 20.0;
77 /* (8*BASEDIGITS_DP64*log10of2) ' exp(-x) insignificant c.f. exp(x) */
78
79 /* Tabulated values of sinh(i) and cosh(i) for i = 0,...,36. */
80
81 static const double sinh_lead[ 37] = {
82 0.00000000000000000000e+00, /* 0x0000000000000000 */
83 1.17520119364380137839e+00, /* 0x3ff2cd9fc44eb982 */
84 3.62686040784701857476e+00, /* 0x400d03cf63b6e19f */
85 1.00178749274099008204e+01, /* 0x40240926e70949ad */
86 2.72899171971277496596e+01, /* 0x403b4a3803703630 */
87 7.42032105777887522891e+01, /* 0x40528d0166f07374 */
88 2.01713157370279219549e+02, /* 0x406936d22f67c805 */
89 5.48316123273246489589e+02, /* 0x408122876ba380c9 */
90 1.49047882578955000099e+03, /* 0x409749ea514eca65 */
91 4.05154190208278987484e+03, /* 0x40afa7157430966f */
92 1.10132328747033916443e+04, /* 0x40c5829dced69991 */
93 2.99370708492480553105e+04, /* 0x40dd3c4488cb48d6 */
94 8.13773957064298447222e+04, /* 0x40f3de1654d043f0 */
95 2.21206696003330085659e+05, /* 0x410b00b5916a31a5 */
96 6.01302142081972560845e+05, /* 0x412259ac48bef7e3 */
97 1.63450868623590236530e+06, /* 0x4138f0ccafad27f6 */
98 4.44305526025387924165e+06, /* 0x4150f2ebd0a7ffe3 */
99 1.20774763767876271158e+07, /* 0x416709348c0ea4ed */
100 3.28299845686652474105e+07, /* 0x417f4f22091940bb */
101 8.92411504815936237574e+07, /* 0x419546d8f9ed26e1 */
102 2.42582597704895108938e+08, /* 0x41aceb088b68e803 */
103 6.59407867241607308388e+08, /* 0x41c3a6e1fd9eecfd */
104 1.79245642306579566002e+09, /* 0x41dab5adb9c435ff */
105 4.87240172312445068359e+09, /* 0x41f226af33b1fdc0 */
106 1.32445610649217357635e+10, /* 0x4208ab7fb5475fb7 */
107 3.60024496686929321289e+10, /* 0x4220c3d3920962c8 */
108 9.78648047144193725586e+10, /* 0x4236c932696a6b5c */
109 2.66024120300899291992e+11, /* 0x424ef822f7f6731c */
110 7.23128532145737548828e+11, /* 0x42650bba3796379a */
111 1.96566714857202099609e+12, /* 0x427c9aae4631c056 */
112 5.34323729076223046875e+12, /* 0x429370470aec28ec */
113 1.45244248326237109375e+13, /* 0x42aa6b765d8cdf6c */
114 3.94814800913403437500e+13, /* 0x42c1f43fcc4b662c */
115 1.07321789892958031250e+14, /* 0x42d866f34a725782 */
116 2.91730871263727437500e+14, /* 0x42f0953e2f3a1ef7 */
117 7.93006726156715250000e+14, /* 0x430689e221bc8d5a */
118 2.15561577355759750000e+15}; /* 0x431ea215a1d20d76 */
119
120 static const double cosh_lead[ 37] = {
121 1.00000000000000000000e+00, /* 0x3ff0000000000000 */
122 1.54308063481524371241e+00, /* 0x3ff8b07551d9f550 */
123 3.76219569108363138810e+00, /* 0x400e18fa0df2d9bc */
124 1.00676619957777653269e+01, /* 0x402422a497d6185e */
125 2.73082328360164865444e+01, /* 0x403b4ee858de3e80 */
126 7.42099485247878334349e+01, /* 0x40528d6fcbeff3a9 */
127 2.01715636122455890700e+02, /* 0x406936e67db9b919 */
128 5.48317035155212010977e+02, /* 0x4081228949ba3a8b */
129 1.49047916125217807348e+03, /* 0x409749eaa93f4e76 */
130 4.05154202549259389343e+03, /* 0x40afa715845d8894 */
131 1.10132329201033226127e+04, /* 0x40c5829dd053712d */
132 2.99370708659497577173e+04, /* 0x40dd3c4489115627 */
133 8.13773957125740562333e+04, /* 0x40f3de1654d6b543 */
134 2.21206696005590405548e+05, /* 0x410b00b5916b6105 */
135 6.01302142082804115489e+05, /* 0x412259ac48bf13ca */
136 1.63450868623620807193e+06, /* 0x4138f0ccafad2d17 */
137 4.44305526025399193168e+06, /* 0x4150f2ebd0a8005c */
138 1.20774763767876680940e+07, /* 0x416709348c0ea503 */
139 3.28299845686652623117e+07, /* 0x417f4f22091940bf */
140 8.92411504815936237574e+07, /* 0x419546d8f9ed26e1 */
141 2.42582597704895138741e+08, /* 0x41aceb088b68e804 */
142 6.59407867241607308388e+08, /* 0x41c3a6e1fd9eecfd */
143 1.79245642306579566002e+09, /* 0x41dab5adb9c435ff */
144 4.87240172312445068359e+09, /* 0x41f226af33b1fdc0 */
145 1.32445610649217357635e+10, /* 0x4208ab7fb5475fb7 */
146 3.60024496686929321289e+10, /* 0x4220c3d3920962c8 */
147 9.78648047144193725586e+10, /* 0x4236c932696a6b5c */
148 2.66024120300899291992e+11, /* 0x424ef822f7f6731c */
149 7.23128532145737548828e+11, /* 0x42650bba3796379a */
150 1.96566714857202099609e+12, /* 0x427c9aae4631c056 */
151 5.34323729076223046875e+12, /* 0x429370470aec28ec */
152 1.45244248326237109375e+13, /* 0x42aa6b765d8cdf6c */
153 3.94814800913403437500e+13, /* 0x42c1f43fcc4b662c */
154 1.07321789892958031250e+14, /* 0x42d866f34a725782 */
155 2.91730871263727437500e+14, /* 0x42f0953e2f3a1ef7 */
156 7.93006726156715250000e+14, /* 0x430689e221bc8d5a */
157 2.15561577355759750000e+15}; /* 0x431ea215a1d20d76 */
158
159 unsigned long long ux, aux, xneg;
160 unsigned int uhx;
161 double x = fx, y, z, z1, z2;
162 int m;
163
164 /* Special cases */
165
166 GET_BITS_DP64(x, ux);
167 aux = ux & ~SIGNBIT_DP64;
168 if (aux < 0x3f10000000000000) /* |x| small enough that cosh(x) = 1 */
169 {
170 if (aux == 0) return (float)1.0; /* with no inexact */
171 if (LAMBDA_DP64 + x > 1.0) return valf_with_flags((float)1.0, AMD_F_INEXACT); /* with inexact */
172 }
173 else if (aux >= PINFBITPATT_DP64) /* |x| is NaN or Inf */
174 {
175 if (aux > PINFBITPATT_DP64) /* x is NaN */
176 {
177 GET_BITS_SP32(fx, uhx);
178 return _handle_errorf("coshf",OP_COSH,uhx|0x00400000,_DOMAIN, 0,
179 EDOM, fx, 0.0, 1);
180 }
181 else /* x is infinity */
182 return infinityf_with_flags(0);
183 }
184 xneg = (aux != ux);
185
186 y = x;
187 if (xneg) y = -x;
188
189 if (y >= max_cosh_arg)
190 /* Return +infinity with overflow flag. */
191 return _handle_errorf("coshf",OP_COSH,PINFBITPATT_SP32,_OVERFLOW,
193// z = infinity_with_flags(AMD_F_OVERFLOW);
194 else if (y >= small_threshold)
195 {
196 /* In this range y is large enough so that
197 the negative exponential is negligible,
198 so cosh(y) is approximated by sign(x)*exp(y)/2. The
199 code below is an inlined version of that from
200 exp() with two changes (it operates on
201 y instead of x, and the division by 2 is
202 done by reducing m by 1). */
203
204 splitexp(y, 1.0, thirtytwo_by_log2, log2_by_32_lead,
205 log2_by_32_tail, &m, &z1, &z2);
206 m -= 1;
207
208 /* scaleDouble_1 is always safe because the argument x was
209 float, rather than double */
210 z = scaleDouble_1((z1+z2),m);
211 }
212 else
213 {
214 /* In this range we find the integer part y0 of y
215 and the increment dy = y - y0. We then compute
216
217 z = sinh(y) = sinh(y0)cosh(dy) + cosh(y0)sinh(dy)
218 z = cosh(y) = cosh(y0)cosh(dy) + sinh(y0)sinh(dy)
219
220 where sinh(y0) and cosh(y0) are tabulated above. */
221
222 int ind;
223 double dy, dy2, sdy, cdy;
224
225 ind = (int)y;
226 dy = y - ind;
227
228 dy2 = dy*dy;
229
230 sdy = dy + dy*dy2*(0.166666666666666667013899e0 +
231 (0.833333333333329931873097e-2 +
232 (0.198412698413242405162014e-3 +
233 (0.275573191913636406057211e-5 +
234 (0.250521176994133472333666e-7 +
235 (0.160576793121939886190847e-9 +
236 0.7746188980094184251527126e-12*dy2)*dy2)*dy2)*dy2)*dy2)*dy2);
237
238 cdy = 1 + dy2*(0.500000000000000005911074e0 +
239 (0.416666666666660876512776e-1 +
240 (0.138888888889814854814536e-2 +
241 (0.248015872460622433115785e-4 +
242 (0.275573350756016588011357e-6 +
243 (0.208744349831471353536305e-8 +
244 0.1163921388172173692062032e-10*dy2)*dy2)*dy2)*dy2)*dy2)*dy2);
245
246 z = cosh_lead[ind]*cdy + sinh_lead[ind]*sdy;
247 }
248
249// if (xneg) z = - z;
250 return (float)z;
251}
#define LAMBDA_DP64
Definition: libm_util.h:61
#define BASEDIGITS_DP64
Definition: libm_util.h:63
static double float double int float z1
Definition: server.c:81
static double float double int float double float z2
Definition: server.c:81

Referenced by test_math_functions().

◆ erf()

◆ erff()

◆ exp()

◆ exp2()

Definition at line 68 of file mathf.c.

68{ return pow(2.0, x); }
double __cdecl pow(double, double)
Definition: freeldr.c:178

Referenced by Test_ofuncs(), and test_SystemFunction003().

◆ exp2f()

_ACRTIMP float __cdecl exp2f ( float  x)

Definition at line 69 of file mathf.c.

69{ return powf(2.0f, x); }
float __cdecl powf(float, float)
Definition: powf.c:14

◆ expf()

◆ expm1()

◆ expm1f()

_ACRTIMP float __cdecl expm1f ( float  )

◆ fabs()

◆ fabsf()

◆ fdim()

_ACRTIMP double __cdecl fdim ( double  ,
double   
)

◆ fdimf()

_ACRTIMP float __cdecl fdimf ( float  ,
float   
)

◆ floor()

_ACRTIMP double __cdecl floor ( double  x)

Definition at line 18 of file floor.c.

19{
20 /* Load the value as uint64 */
21 unsigned long long u64 = *(unsigned long long*)&x;
22
23 /* Check for NAN */
24 if ((u64 & ~(1ULL << 63)) > 0x7FF0000000000000ull)
25 {
26 /* Set error bit */
27 u64 |= 0x0008000000000000ull;
28 return *(double*)&u64;
29 }
30
31 /* Check if x is positive */
32 if ((u64 & (1ULL << 63)) == 0)
33 {
34 /* Check if it fits into an int64 */
35 if (x < (double)_I64_MAX)
36 {
37 /* Just cast to int64, which will truncate towards 0,
38 which is what we want here.*/
39 return (double)(long long)x;
40 }
41 else
42 {
43 /* The exponent is larger than the fraction bits.
44 This means the number is already an integer. */
45 return x;
46 }
47 }
48 else
49 {
50 /* Check if it fits into an int64 */
51 if (x > (double)_I64_MIN)
52 {
53 /* Check if it is -0 */
54 if (x == -0.)
55 {
56 return -0.;
57 }
58
59 /* Cast to int64 to truncate towards 0. If this matches the
60 input, return it as is, otherwise subtract 1 */
61 double y = (double)(long long)x;
62 return (x == y) ? y : y - 1;
63 }
64 else
65 {
66 /* The exponent is larger than the fraction bits.
67 This means the number is already an integer. */
68 return x;
69 }
70 }
71}
#define long
Definition: qsort.c:33

Referenced by Array_set_length(), Array_slice(), d3drm_color_component(), Date_getTimezoneOffset(), Date_setYear(), day(), day_from_year(), EMF_FixIsotropic(), EmfEnumProc(), floorf(), floorl(), GDI_ROUND(), CAppScrnshotPreview::GetRequestedWidth(), hour_from_time(), HTMLRect_get_bottom(), HTMLRect_get_left(), HTMLRect_get_right(), HTMLRect_get_top(), I10_OUTPUT(), index_from_val(), JSON_stringify(), make_day(), Math_floor(), Math_round(), msl::utilities::SafeInt< T, E >::Min(), min_from_time(), number_to_str(), Number_toPrecision(), Number_toString(), PATH_Arc(), pres_frc(), round(), sample_1d_linear(), sample_2d_linear(), scale_internal(), scale_internal_byte(), scale_internal_float(), scale_internal_int(), scale_internal_short(), scale_internal_ubyte(), scale_internal_uint(), scale_internal_ushort(), scaleInternal3D(), scaleInternalPackedPixel(), sec_from_time(), set_style_pos(), StrFormatByteSizeW(), Test_floor(), TIFFDefaultTransferFunction(), time_clip(), to_integer(), TRACKBAR_ConvertPlaceToPosition(), translate(), VarBstrFromDate(), VarFix(), VarInt(), VarR8Round(), VarRound(), VarUdateFromDate(), wave_generate_tone(), xsltFormatNumberConversion(), and xsltNumberFormatInsertNumbers().

◆ floorf()

_ACRTIMP float __cdecl floorf ( float  x)

Definition at line 40 of file floorf.c.

41{
42 float r;
43 int rexp, xneg;
44 unsigned int ux, ax, ur, mask;
45
46 GET_BITS_SP32(x, ux);
47 ax = ux & (~SIGNBIT_SP32);
48 xneg = (ux != ax);
49
50 if (ax >= 0x4b800000)
51 {
52 /* abs(x) is either NaN, infinity, or >= 2^24 */
53 if (ax > 0x7f800000)
54 /* x is NaN */
55 return _handle_errorf("floorf", OP_FLOOR, ux|0x00400000, _DOMAIN,
56 0, EDOM, x, 0.0F, 1);
57 else
58 return x;
59 }
60 else if (ax < 0x3f800000) /* abs(x) < 1.0 */
61 {
62 if (ax == 0x00000000)
63 /* x is +zero or -zero; return the same zero */
64 return x;
65 else if (xneg) /* x < 0.0 */
66 return -1.0F;
67 else
68 return 0.0F;
69 }
70 else
71 {
72 rexp = ((ux & EXPBITS_SP32) >> EXPSHIFTBITS_SP32) - EXPBIAS_SP32;
73 /* Mask out the bits of r that we don't want */
74 mask = (1 << (EXPSHIFTBITS_SP32 - rexp)) - 1;
75 ur = (ux & ~mask);
76 PUT_BITS_SP32(ur, r);
77 if (xneg && (ux != ur))
78 /* We threw some bits away and x was negative */
79 return r - 1.0F;
80 else
81 return r;
82 }
83}

◆ fma()

_ACRTIMP double __cdecl fma ( double  x,
double  y,
double  z 
)

Definition at line 50 of file stubs.c.

51{
52 // Simplistic implementation
53 return (x * y) + z;
54}

◆ fmaf()

_ACRTIMP float __cdecl fmaf ( float  x,
float  y,
float  z 
)

Definition at line 56 of file stubs.c.

57{
58 // Simplistic implementation
59 return (x * y) + z;
60}

◆ fmax()

_ACRTIMP double __cdecl fmax ( double  ,
double   
)

◆ fmaxf()

_ACRTIMP float __cdecl fmaxf ( float  ,
float   
)

◆ fmin()

◆ fminf()

_ACRTIMP float __cdecl fminf ( float  ,
float   
)

◆ fmod()

◆ fmodf()

◆ frexp()

_ACRTIMP double __cdecl frexp ( double  x,
int e 
)

Definition at line 14 of file frexp.c.

15{
16 union { double d; uint64_t i; } y = { x };
17 int ee = y.i>>52 & 0x7ff;
18
19 if (!ee) {
20 if (x) {
21 x = frexp(x*0x1p64, e);
22 *e -= 64;
23 } else *e = 0;
24 return x;
25 } else if (ee == 0x7ff) {
26 return x;
27 }
28
29 *e = ee - 0x3fe;
30 y.i &= 0x800fffffffffffffull;
31 y.i |= 0x3fe0000000000000ull;
32 return y.d;
33}
UINT64 uint64_t
Definition: types.h:77
double frexp(double x, int *e)
Definition: frexp.c:14

Referenced by frexp(), frexpf(), frexpl(), and pf_output_fp().

◆ frexpf()

static float frexpf ( float  x,
int y 
)
inlinestatic

Definition at line 213 of file math.h.

213{ return frexp(x, y); }
_ACRTIMP double __cdecl frexp(double, int *)
Definition: frexp.c:14

◆ hypot()

static double hypot ( double  x,
double  y 
)
inlinestatic

Definition at line 420 of file math.h.

420{ return _hypot( x, y ); }
_ACRTIMP double __cdecl _hypot(double, double)
Definition: hypot.c:34

Referenced by log10T(), logT(), powT(), and sqrtT().

◆ hypotf()

static float hypotf ( float  x,
float  y 
)
inlinestatic

Definition at line 428 of file math.h.

428{ return _hypotf( x, y ); }
_ACRTIMP float __cdecl _hypotf(float, float)
Definition: hypotf.c:45

◆ ilogb()

_ACRTIMP int __cdecl ilogb ( double  )

◆ ilogbf()

_ACRTIMP int __cdecl ilogbf ( float  )

◆ j0()

static double j0 ( double  x)
inlinestatic

Definition at line 421 of file math.h.

421{ return _j0( x ); }
_ACRTIMP double __cdecl _j0(double)
Definition: j0_y0.c:10

Referenced by generate_xa_rr_attributes(), modfl(), polygon_area(), render_clipped_polygon(), render_polygon(), sample_2d_linear(), and unfilled_polygon().

◆ j1()

◆ jn()

static double jn ( int  n,
double  x 
)
inlinestatic

Definition at line 423 of file math.h.

423{ return _jn( n, x ); }
_ACRTIMP double __cdecl _jn(int, double)
Definition: jn_yn.c:12

◆ ldexp()

_ACRTIMP double __cdecl ldexp ( double  num,
int  exp 
)

Definition at line 1204 of file math.c.

1205{
1206 double z = scalbn(num, exp);
1207
1208 if (isfinite(num) && !isfinite(z))
1209 return math_error(_OVERFLOW, "ldexp", num, exp, z);
1210 if (num && isfinite(num) && !z)
1211 return math_error(_UNDERFLOW, "ldexp", num, exp, z);
1212 return z;
1213}
#define isfinite(x)
Definition: math.h:363
_ACRTIMP double __cdecl scalbn(double, int)
Definition: scalbn.c:14
#define _UNDERFLOW
Definition: math.c:65
double math_error(int type, const char *name, double arg1, double arg2, double retval)
Definition: math.c:125
#define _OVERFLOW
Definition: math.c:64

Referenced by _scalb(), _scalbf(), ldexpf(), and ldexpl().

◆ ldexpf()

static float ldexpf ( float  x,
int  y 
)
inlinestatic

Definition at line 247 of file math.h.

247{ return ldexp(x, y); }
_ACRTIMP double __cdecl ldexp(double, int)
Definition: math.c:1204

◆ lgamma()

_ACRTIMP double __cdecl lgamma ( double  )

◆ lgammaf()

_ACRTIMP float __cdecl lgammaf ( float  )

◆ llrint()

__MINGW_EXTENSION __CRT_INLINE long long __cdecl llrint ( double  x)

Definition at line 395 of file mingw_math.h.

396 {
397 __MINGW_EXTENSION long long retval = 0ll;
398 __asm__ __volatile__ \
399 ("fistpll %0" : "=m" (retval) : "t" (x) : "st"); \
400 return retval;
401 }
#define __MINGW_EXTENSION
Definition: _mingw.h:166
w ll
Definition: byte_order.h:167
__asm__(".p2align 4, 0x90\n" ".seh_proc __seh2_global_filter_func\n" "__seh2_global_filter_func:\n" "\tsub %rbp, %rax\n" "\tpush %rbp\n" "\t.seh_pushreg %rbp\n" "\tsub $32, %rsp\n" "\t.seh_stackalloc 32\n" "\t.seh_endprologue\n" "\tsub %rax, %rdx\n" "\tmov %rdx, %rbp\n" "\tjmp *%r8\n" "__seh2_global_filter_func_exit:\n" "\t.p2align 4\n" "\tadd $32, %rsp\n" "\tpop %rbp\n" "\tret\n" "\t.seh_endproc")

◆ llrintf()

__MINGW_EXTENSION __CRT_INLINE long long __cdecl llrintf ( float  x)

Definition at line 403 of file mingw_math.h.

404 {
405 __MINGW_EXTENSION long long retval = 0ll;
406 __asm__ __volatile__ \
407 ("fistpll %0" : "=m" (retval) : "t" (x) : "st"); \
408 return retval;
409 }

◆ llround()

_ACRTIMP __int64 __cdecl llround ( double  )

◆ llroundf()

_ACRTIMP __int64 __cdecl llroundf ( float  )

◆ log()

Definition at line 184 of file freeldr.c.

185{
186 __debugbreak();
187 return 0.0;
188}
void __cdecl __debugbreak(void)
Definition: intrin_ppc.h:698

◆ log10()

◆ log10f()

◆ log1p()

◆ log1pf()

_ACRTIMP float __cdecl log1pf ( float  )

◆ log2()

Definition at line 62 of file stubs.c.

63{
64 // Simplistic implementation: log2(x) = log(x) / log(2)
65 return log(x) * M_LOG2E;
66}
#define M_LOG2E
Definition: math.h:405

Referenced by exp2(), logbase2(), and pres_log().

◆ log2f()

_ACRTIMP float __cdecl log2f ( float  x)

Definition at line 68 of file stubs.c.

69{
70 return (float)log2((double)x);
71}
double log2(double x)
Definition: stubs.c:62

◆ logb()

__CRT_INLINE double __cdecl logb ( double  x)

Definition at line 243 of file mingw_math.h.

244 {
245 double res = 0.0;
246 __asm__ __volatile__ ("fxtract\n\t"
247 "fstp %%st" : "=t" (res) : "0" (x));
248 return res;
249 }
GLuint res
Definition: glext.h:9613

◆ logbf()

__CRT_INLINE float __cdecl logbf ( float  x)

Definition at line 251 of file mingw_math.h.

252 {
253 float res = 0.0F;
254 __asm__ __volatile__ ("fxtract\n\t"
255 "fstp %%st" : "=t" (res) : "0" (x));
256 return res;
257 }

◆ logf()

_ACRTIMP float __cdecl logf ( float  x)

This file has no copyright assigned and is placed in the Public Domain. This file is part of the w64 mingw-runtime package. No warranty is given; refer to the file DISCLAIMER.PD within this package.

Definition at line 12 of file logf.c.

13{
14 return ((float)log((double)x));
15}

Referenced by Test_logf_approx(), Test_logf_exact(), and wined3d_device_set_light().

◆ lrint()

◆ lrintf()

__CRT_INLINE long __cdecl lrintf ( float  x)

Definition at line 379 of file mingw_math.h.

380 {
381 long retval = 0;
382 __asm__ __volatile__ \
383 ("fistpl %0" : "=m" (retval) : "t" (x) : "st"); \
384 return retval;
385 }

Referenced by PerformSampleRateConversion().

◆ lround()

◆ lroundf()

◆ modf()

_ACRTIMP double __cdecl modf ( double  x,
double iptr 
)

Definition at line 30 of file modf.c.

31{
32 /* modf splits the argument x into integer and fraction parts,
33 each with the same sign as x. */
34
35
36 long long xexp;
37 unsigned long long ux, ax, mask;
38
39 GET_BITS_DP64(x, ux);
40 ax = ux & (~SIGNBIT_DP64);
41
42 if (ax >= 0x4340000000000000)
43 {
44 /* abs(x) is either NaN, infinity, or >= 2^53 */
45 if (ax > 0x7ff0000000000000)
46 {
47 /* x is NaN */
48 *iptr = x;
49 return x + x; /* Raise invalid if it is a signalling NaN */
50 }
51 else
52 {
53 /* x is infinity or large. Return zero with the sign of x */
54 *iptr = x;
56 return x;
57 }
58 }
59 else if (ax < 0x3ff0000000000000)
60 {
61 /* abs(x) < 1.0. Set iptr to zero with the sign of x
62 and return x. */
63 PUT_BITS_DP64(ux & SIGNBIT_DP64, *iptr);
64 return x;
65 }
66 else
67 {
68 xexp = ((ux & EXPBITS_DP64) >> EXPSHIFTBITS_DP64) - EXPBIAS_DP64;
69 /* Mask out the bits of x that we don't want */
70 mask = 1;
71 mask = (mask << (EXPSHIFTBITS_DP64 - xexp)) - 1;
72 PUT_BITS_DP64(ux & ~mask, *iptr);
73 return x - *iptr;
74 }
75
76}

Referenced by cvt(), logic_dbl2int(), modff(), modfl(), rpn_dec2dms(), rpn_dms2dec(), rpn_exp10(), rpn_frac(), rpn_int(), rpn_mod_f(), rpn_shl_f(), and rpn_shr_f().

◆ modff()

_ACRTIMP float __cdecl modff ( float  x,
float iptr 
)

Definition at line 30 of file modff.c.

31{
32 /* modff splits the argument x into integer and fraction parts,
33 each with the same sign as x. */
34
35 unsigned int ux, mask;
36 int xexp;
37
38 GET_BITS_SP32(x, ux);
39 xexp = ((ux & (~SIGNBIT_SP32)) >> EXPSHIFTBITS_SP32) - EXPBIAS_SP32;
40
41 if (xexp < 0)
42 {
43 /* abs(x) < 1.0. Set iptr to zero with the sign of x
44 and return x. */
45 PUT_BITS_SP32(ux & SIGNBIT_SP32, *iptr);
46 return x;
47 }
48 else if (xexp < EXPSHIFTBITS_SP32)
49 {
50 /* x lies between 1.0 and 2**(24) */
51 /* Mask out the bits of x that we don't want */
52 mask = (1 << (EXPSHIFTBITS_SP32 - xexp)) - 1;
53 PUT_BITS_SP32(ux & ~mask, *iptr);
54 return x - *iptr;
55 }
56 else if ((ux & (~SIGNBIT_SP32)) > 0x7f800000)
57 {
58 /* x is NaN */
59 *iptr = x;
60 return x + x; /* Raise invalid if it is a signalling NaN */
61 }
62 else
63 {
64 /* x is infinity or large. Set iptr to x and return zero
65 with the sign of x. */
66 *iptr = x;
68 return x;
69 }
70}

◆ nearbyint()

_ACRTIMP double __cdecl nearbyint ( double  )

◆ nearbyintf()

_ACRTIMP float __cdecl nearbyintf ( float  )

◆ nextafter()

_ACRTIMP double __cdecl nextafter ( double  x,
double  y 
)

Definition at line 13 of file nextafter.c.

14{
15 union {double f; uint64_t i;} ux={x}, uy={y};
16 uint64_t ax, ay;
17 int e;
18
19 if (isnan(x) || isnan(y))
20 return x + y;
21 if (ux.i == uy.i)
22 return y;
23 ax = ux.i & ~0ULL/2;
24 ay = uy.i & ~0ULL/2;
25 if (ax == 0) {
26 if (ay == 0)
27 return y;
28 ux.i = (uy.i & 1ULL<<63) | 1;
29 } else if (ax > ay || ((ux.i ^ uy.i) & 1ULL<<63))
30 ux.i--;
31 else
32 ux.i++;
33 e = ux.i >> 52 & 0x7ff;
34 /* raise overflow if ux.f is infinite and x is finite */
35 if (e == 0x7ff)
36 FORCE_EVAL(x+x);
37 /* raise underflow if ux.f is subnormal or zero */
38 if (e == 0)
39 FORCE_EVAL(x*x + ux.f*ux.f);
40 return ux.f;
41}
#define isnan(x)
Definition: math.h:360
#define FORCE_EVAL(x)
Definition: libm.h:64
if(dx< 0)
Definition: linetemp.h:194
#define ULL(a, b)
Definition: format_msg.c:27

◆ nextafterf()

_ACRTIMP float __cdecl nextafterf ( float  x,
float  y 
)

Definition at line 13 of file nextafterf.c.

14{
15 union {float f; uint32_t i;} ux={x}, uy={y};
16 uint32_t ax, ay, e;
17
18 if (isnanf(x) || isnanf(y))
19 return x + y;
20 if (ux.i == uy.i)
21 return y;
22 ax = ux.i & 0x7fffffff;
23 ay = uy.i & 0x7fffffff;
24 if (ax == 0) {
25 if (ay == 0)
26 return y;
27 ux.i = (uy.i & 0x80000000) | 1;
28 } else if (ax > ay || ((ux.i ^ uy.i) & 0x80000000))
29 ux.i--;
30 else
31 ux.i++;
32 e = ux.i & 0x7f800000;
33 /* raise overflow if ux.f is infinite and x is finite */
34 if (e == 0x7f800000)
35 FORCE_EVAL(x+x);
36 /* raise underflow if ux.f is subnormal or zero */
37 if (e == 0)
38 FORCE_EVAL(x*x + ux.f*ux.f);
39 return ux.f;
40}
UINT32 uint32_t
Definition: types.h:75
#define isnanf
Definition: libm.h:29

◆ pow()

_ACRTIMP double __cdecl pow ( double  x,
double  y 
)

Definition at line 178 of file freeldr.c.

179{
180 __debugbreak();
181 return 0.0;
182}

Referenced by powf(), and powl().

◆ powf()

_ACRTIMP float __cdecl powf ( float  x,
float  y 
)

Definition at line 14 of file powf.c.

15{
16 return (float)pow((double)x, (double)y);
17}
double __cdecl pow(double x, double y)
Definition: freeldr.c:178

Referenced by __libm_sse2_powf(), apply_image_attributes(), exp2f(), flatten_bezier(), float_16_to_32(), float_24_to_32(), and to_sRGB_component().

◆ remainder()

_ACRTIMP double __cdecl remainder ( double  x,
double  y 
)

Definition at line 75 of file remainder.c.

79{
80 double dx, dy, scale, w, t, v, c, cc;
81 int i, ntimes, xexp, yexp;
82 unsigned long long u, ux, uy, ax, ay, todd;
83 unsigned int sw;
84
85 dx = x;
86 dy = y;
87
88
89 GET_BITS_DP64(dx, ux);
90 GET_BITS_DP64(dy, uy);
91 ax = ux & ~SIGNBIT_DP64;
92 ay = uy & ~SIGNBIT_DP64;
93 xexp = (int)((ux & EXPBITS_DP64) >> EXPSHIFTBITS_DP64);
94 yexp = (int)((uy & EXPBITS_DP64) >> EXPSHIFTBITS_DP64);
95
96 if (xexp < 1 || xexp > BIASEDEMAX_DP64 ||
97 yexp < 1 || yexp > BIASEDEMAX_DP64)
98 {
99 /* x or y is zero, denormalized, NaN or infinity */
100 if (xexp > BIASEDEMAX_DP64)
101 {
102 /* x is NaN or infinity */
103 if (ux & MANTBITS_DP64)
104 {
105 /* x is NaN */
106 return _handle_error(_FUNCNAME, _OPERATION, ux|0x0008000000000000, _DOMAIN, 0,
107 EDOM, x, y, 2);
108 }
109 else
110 {
111 /* x is infinity; result is NaN */
113 AMD_F_INVALID, EDOM, x, y, 2);
114 }
115 }
116 else if (yexp > BIASEDEMAX_DP64)
117 {
118 /* y is NaN or infinity */
119 if (uy & MANTBITS_DP64)
120 {
121 /* y is NaN */
122 return _handle_error(_FUNCNAME, _OPERATION, uy|0x0008000000000000, _DOMAIN, 0,
123 EDOM, x, y, 2);
124 }
125 else
126 {
127#ifdef _CRTBLD_C9X
128 /* C99 return for y = +-inf is x */
129 return x;
130#else
131 /* y is infinity; result is indefinite */
133 AMD_F_INVALID, EDOM, x, y, 2);
134#endif
135 }
136 }
137 else if (ax == 0x0000000000000000)
138 {
139 /* x is zero */
140 if (ay == 0x0000000000000000)
141 {
142 /* y is zero */
144 AMD_F_INVALID, EDOM, x, y, 2);
145 }
146 else
147 /* C99 return for x = 0 must preserve sign */
148 return x;
149 }
150 else if (ay == 0x0000000000000000)
151 {
152 /* y is zero */
154 AMD_F_INVALID, EDOM, x, y, 2);
155 }
156
157 /* We've exhausted all other possibilities. One or both of x and
158 y must be denormalized */
159 if (xexp < 1)
160 {
161 /* x is denormalized. Figure out its exponent. */
162 u = ax;
163 while (u < IMPBIT_DP64)
164 {
165 xexp--;
166 u <<= 1;
167 }
168 }
169 if (yexp < 1)
170 {
171 /* y is denormalized. Figure out its exponent. */
172 u = ay;
173 while (u < IMPBIT_DP64)
174 {
175 yexp--;
176 u <<= 1;
177 }
178 }
179 }
180 else if (ax == ay)
181 {
182 /* abs(x) == abs(y); return zero with the sign of x */
184 return dx;
185 }
186
187 /* Set x = abs(x), y = abs(y) */
189 PUT_BITS_DP64(ay, dy);
190
191 if (ax < ay)
192 {
193 /* abs(x) < abs(y) */
194#if !defined(COMPILING_FMOD)
195 if (dx > 0.5*dy)
196 dx -= dy;
197#endif
198 return x < 0.0? -dx : dx;
199 }
200
201 /* Save the current floating-point status word. We need
202 to do this because the remainder function is always
203 exact for finite arguments, but our algorithm causes
204 the inexact flag to be raised. We therefore need to
205 restore the entry status before exiting. */
206 sw = get_fpsw_inline();
207
208 /* Set ntimes to the number of times we need to do a
209 partial remainder. If the exponent of x is an exact multiple
210 of 52 larger than the exponent of y, and the mantissa of x is
211 less than the mantissa of y, ntimes will be one too large
212 but it doesn't matter - it just means that we'll go round
213 the loop below one extra time. */
214 if (xexp <= yexp)
215 ntimes = 0;
216 else
217 ntimes = (xexp - yexp) / 52;
218
219 if (ntimes == 0)
220 {
221 w = dy;
222 scale = 1.0;
223 }
224 else
225 {
226 /* Set w = y * 2^(52*ntimes) */
227 w = scaleDouble_3(dy, ntimes * 52);
228
229 /* Set scale = 2^(-52) */
230 PUT_BITS_DP64((unsigned long long)(-52 + EXPBIAS_DP64) << EXPSHIFTBITS_DP64,
231 scale);
232 }
233
234
235 /* Each time round the loop we compute a partial remainder.
236 This is done by subtracting a large multiple of w
237 from x each time, where w is a scaled up version of y.
238 The subtraction must be performed exactly in quad
239 precision, though the result at each stage can
240 fit exactly in a double precision number. */
241 for (i = 0; i < ntimes; i++)
242 {
243 /* t is the integer multiple of w that we will subtract.
244 We use a truncated value for t.
245
246 N.B. w has been chosen so that the integer t will have
247 at most 52 significant bits. This is the amount by
248 which the exponent of the partial remainder dx gets reduced
249 every time around the loop. In theory we could use
250 53 bits in t, but the quad precision multiplication
251 routine dekker_mul12 does not allow us to do that because
252 it loses the last (106th) bit of its quad precision result. */
253
254 /* Set dx = dx - w * t, where t is equal to trunc(dx/w). */
255 t = (double)(long long)(dx / w);
256 /* At this point, t may be one too large due to
257 rounding of dx/w */
258
259 /* Compute w * t in quad precision */
260 dekker_mul12(w, t, &c, &cc);
261
262 /* Subtract w * t from dx */
263 v = dx - c;
264 dx = v + (((dx - v) - c) - cc);
265
266 /* If t was one too large, dx will be negative. Add back
267 one w */
268 /* It might be possible to speed up this loop by finding
269 a way to compute correctly truncated t directly from dx and w.
270 We would then avoid the need for this check on negative dx. */
271 if (dx < 0.0)
272 dx += w;
273
274 /* Scale w down by 2^(-52) for the next iteration */
275 w *= scale;
276 }
277
278 /* One more time */
279 /* Variable todd says whether the integer t is odd or not */
280 t = (double)(long long)(dx / w);
281 todd = ((long long)(dx / w)) & 1;
282 dekker_mul12(w, t, &c, &cc);
283 v = dx - c;
284 dx = v + (((dx - v) - c) - cc);
285 if (dx < 0.0)
286 {
287 todd = !todd;
288 dx += w;
289 }
290
291 /* At this point, dx lies in the range [0,dy) */
292#if !defined(COMPILING_FMOD)
293 /* For the fmod function, we're done apart from setting
294 the correct sign. */
295 /* For the remainder function, we need to adjust dx
296 so that it lies in the range (-y/2, y/2] by carefully
297 subtracting w (== dy == y) if necessary. The rigmarole
298 with todd is to get the correct sign of the result
299 when x/y lies exactly half way between two integers,
300 when we need to choose the even integer. */
301 if (ay < 0x7fd0000000000000)
302 {
303 if (dx + dx > w || (todd && (dx + dx == w)))
304 dx -= w;
305 }
306 else if (dx > 0.5 * w || (todd && (dx == 0.5 * w)))
307 dx -= w;
308
309#endif
310
311 /* **** N.B. for some reason this breaks the 32 bit version
312 of remainder when compiling with optimization. */
313 /* Restore the entry status flags */
314 set_fpsw_inline(sw);
315
316 /* Set the result sign according to input argument x */
317 return x < 0.0? -dx : dx;
318
319}
GLenum GLenum GLenum GLenum GLenum scale
Definition: glext.h:9032
GLubyte GLubyte GLubyte GLubyte w
Definition: glext.h:6102
uint32_t cc
Definition: isohybrid.c:75
#define IMPBIT_DP64
Definition: libm_util.h:50
#define INDEFBITPATT_DP64
Definition: libm_util.h:52
#define _FUNCNAME
#define _OPERATION
static void dekker_mul12(double x, double y, double *z, double *zz)
Definition: remainder.c:50

Referenced by cut_misaligned_tail(), IDirectSoundBufferImpl_Lock(), layout_recall_range(), memcmp_blocks(), positive_remainder(), stripe_next_unit(), TAB_SetItemBounds(), test_RegQueryValueExPerformanceData(), VARIANT_DecScale(), VARIANT_DI_div(), VARIANT_DI_mul(), VARIANT_DI_tostringW(), VARIANT_do_division(), VARIANT_int_addlossy(), VARIANT_int_divbychar(), widGetPosition(), wodGetPosition(), and write_integer().

◆ remainderf()

_ACRTIMP float __cdecl remainderf ( float  x,
float  y 
)

Definition at line 60 of file remainderf.c.

64{
65 double dx, dy, scale, w, t;
66 int i, ntimes, xexp, yexp;
67 unsigned long long ux, uy, ax, ay;
68
69 unsigned int sw;
70
71 dx = x;
72 dy = y;
73
74
75 GET_BITS_DP64(dx, ux);
76 GET_BITS_DP64(dy, uy);
77 ax = ux & ~SIGNBIT_DP64;
78 ay = uy & ~SIGNBIT_DP64;
79 xexp = (int)((ux & EXPBITS_DP64) >> EXPSHIFTBITS_DP64);
80 yexp = (int)((uy & EXPBITS_DP64) >> EXPSHIFTBITS_DP64);
81
82 if (xexp < 1 || xexp > BIASEDEMAX_DP64 ||
83 yexp < 1 || yexp > BIASEDEMAX_DP64)
84 {
85 /* x or y is zero, NaN or infinity (neither x nor y can be
86 denormalized because we promoted from float to double) */
87 if (xexp > BIASEDEMAX_DP64)
88 {
89 /* x is NaN or infinity */
90 if (ux & MANTBITS_DP64)
91 {
92 /* x is NaN */
93 unsigned int ufx;
94 GET_BITS_SP32(x, ufx);
95 return _handle_errorf(_FUNCNAME, _OPERATION, ufx|0x00400000, _DOMAIN, 0,
96 EDOM, x, y, 2);
97 }
98 else
99 {
100 /* x is infinity; result is NaN */
102 AMD_F_INVALID, EDOM, x, y, 2);
103 }
104 }
105 else if (yexp > BIASEDEMAX_DP64)
106 {
107 /* y is NaN or infinity */
108 if (uy & MANTBITS_DP64)
109 {
110 /* y is NaN */
111 unsigned int ufy;
112 GET_BITS_SP32(y, ufy);
113 return _handle_errorf(_FUNCNAME, _OPERATION, ufy|0x00400000, _DOMAIN, 0,
114 EDOM, x, y, 2);
115 }
116 else
117 {
118#ifdef _CRTBLD_C9X
119 /* C99 return for y = +-inf is x */
120 return x;
121#else
122 /* y is infinity; result is indefinite */
124 AMD_F_INVALID, EDOM, x, y, 2);
125#endif
126 }
127 }
128 else if (xexp < 1)
129 {
130 /* x must be zero (cannot be denormalized) */
131 if (yexp < 1)
132 {
133 /* y must be zero (cannot be denormalized) */
135 AMD_F_INVALID, EDOM, x, y, 2);
136 }
137 else
138 /* C99 return for x = 0 must preserve sign */
139 return x;
140 }
141 else
142 {
143 /* y must be zero */
145 AMD_F_INVALID, EDOM, x, y, 2);
146 }
147 }
148 else if (ax == ay)
149 {
150 /* abs(x) == abs(y); return zero with the sign of x */
152 return (float)dx;
153 }
154
155 /* Set dx = abs(x), dy = abs(y) */
157 PUT_BITS_DP64(ay, dy);
158
159 if (ax < ay)
160 {
161 /* abs(x) < abs(y) */
162#if !defined(COMPILING_FMOD)
163 if (dx > 0.5*dy)
164 dx -= dy;
165#endif
166 return (float)(x < 0.0? -dx : dx);
167 }
168
169 /* Save the current floating-point status word. We need
170 to do this because the remainder function is always
171 exact for finite arguments, but our algorithm causes
172 the inexact flag to be raised. We therefore need to
173 restore the entry status before exiting. */
174 sw = get_fpsw_inline();
175
176 /* Set ntimes to the number of times we need to do a
177 partial remainder. If the exponent of x is an exact multiple
178 of 24 larger than the exponent of y, and the mantissa of x is
179 less than the mantissa of y, ntimes will be one too large
180 but it doesn't matter - it just means that we'll go round
181 the loop below one extra time. */
182 if (xexp <= yexp)
183 {
184 ntimes = 0;
185 w = dy;
186 scale = 1.0;
187 }
188 else
189 {
190 ntimes = (xexp - yexp) / 24;
191
192 /* Set w = y * 2^(24*ntimes) */
193 PUT_BITS_DP64((unsigned long long)(ntimes * 24 + EXPBIAS_DP64) << EXPSHIFTBITS_DP64,
194 scale);
195 w = scale * dy;
196 /* Set scale = 2^(-24) */
197 PUT_BITS_DP64((unsigned long long)(-24 + EXPBIAS_DP64) << EXPSHIFTBITS_DP64,
198 scale);
199 }
200
201
202 /* Each time round the loop we compute a partial remainder.
203 This is done by subtracting a large multiple of w
204 from x each time, where w is a scaled up version of y.
205 The subtraction can be performed exactly when performed
206 in double precision, and the result at each stage can
207 fit exactly in a single precision number. */
208 for (i = 0; i < ntimes; i++)
209 {
210 /* t is the integer multiple of w that we will subtract.
211 We use a truncated value for t. */
212 t = (double)((int)(dx / w));
213 dx -= w * t;
214 /* Scale w down by 2^(-24) for the next iteration */
215 w *= scale;
216 }
217
218 /* One more time */
219#if defined(COMPILING_FMOD)
220 t = (double)((int)(dx / w));
221 dx -= w * t;
222#else
223 {
224 unsigned int todd;
225 /* Variable todd says whether the integer t is odd or not */
226 t = (double)((int)(dx / w));
227 todd = ((int)(dx / w)) & 1;
228 dx -= w * t;
229
230 /* At this point, dx lies in the range [0,dy) */
231 /* For the remainder function, we need to adjust dx
232 so that it lies in the range (-y/2, y/2] by carefully
233 subtracting w (== dy == y) if necessary. */
234 if (dx > 0.5 * w || ((dx == 0.5 * w) && todd))
235 dx -= w;
236 }
237#endif
238
239 /* **** N.B. for some reason this breaks the 32 bit version
240 of remainder when compiling with optimization. */
241 /* Restore the entry status flags */
242 set_fpsw_inline(sw);
243
244 /* Set the result sign according to input argument x */
245 return (float)(x < 0.0? -dx : dx);
246
247}
#define _FUNCNAME
#define _OPERATION

◆ remquo()

_ACRTIMP double __cdecl remquo ( double  ,
double  ,
int  
)

◆ remquof()

_ACRTIMP float __cdecl remquof ( float  ,
float  ,
int  
)

◆ rint()

__CRT_INLINE double __cdecl rint ( double  x)

Definition at line 350 of file mingw_math.h.

351 {
352 double retval = 0.0;
353 __asm__ __volatile__ ("frndint;": "=t" (retval) : "0" (x));
354 return retval;
355 }

◆ rintf()

__CRT_INLINE float __cdecl rintf ( float  x)

Definition at line 357 of file mingw_math.h.

358 {
359 float retval = 0.0;
360 __asm__ __volatile__ ("frndint;" : "=t" (retval) : "0" (x) );
361 return retval;
362 }

◆ round()

_ACRTIMP double __cdecl round ( double  arg)

Definition at line 10 of file round.c.

11{
12 if (arg < 0.0)
13 return ceil(arg - 0.5);
14 else
15 return floor(arg + 0.5);
16}
_ACRTIMP double __cdecl ceil(double)
Definition: ceil.c:18
_ACRTIMP double __cdecl floor(double)
Definition: floor.c:18

◆ roundf()

_ACRTIMP float __cdecl roundf ( float  arg)

Definition at line 10 of file roundf.c.

11{
12 if (arg < 0.0)
13 return ceilf(arg - 0.5);
14 else
15 return floorf(arg + 0.5);
16}
#define ceilf(x)
Definition: mymath.h:62
#define floorf(x)
Definition: mymath.h:65

Referenced by rintf(), and Test_roundf().

◆ scalbln()

_ACRTIMP double __cdecl scalbln ( double  ,
__msvcrt_long   
)

◆ scalblnf()

_ACRTIMP float __cdecl scalblnf ( float  ,
__msvcrt_long   
)

◆ scalbn()

_ACRTIMP double __cdecl scalbn ( double  x,
int  n 
)

Definition at line 14 of file scalbn.c.

15{
16 union {double f; uint64_t i;} u;
17 double_t y = x;
18
19 if (n > 1023) {
20 y *= 0x1p1023;
21 n -= 1023;
22 if (n > 1023) {
23 y *= 0x1p1023;
24 n -= 1023;
25 if (n > 1023)
26 n = 1023;
27 }
28 } else if (n < -1022) {
29 /* make sure final n < -53 to avoid double
30 rounding in the subnormal range */
31 y *= 0x1p-1022 * 0x1p53;
32 n += 1022 - 53;
33 if (n < -1022) {
34 y *= 0x1p-1022 * 0x1p53;
35 n += 1022 - 53;
36 if (n < -1022)
37 n = -1022;
38 }
39 }
40 u.i = (uint64_t)(0x3ff+n)<<52;
41 x = y * u.f;
42 return x;
43}
#define uint64_t
Definition: nsiface.idl:62

Referenced by ldexp().

◆ scalbnf()

_ACRTIMP float __cdecl scalbnf ( float  x,
int  n 
)

Definition at line 14 of file scalbnf.c.

15{
16 union {float f; uint32_t i;} u;
17 float_t y = x;
18
19 if (n > 127) {
20 y *= 0x1p127f;
21 n -= 127;
22 if (n > 127) {
23 y *= 0x1p127f;
24 n -= 127;
25 if (n > 127)
26 n = 127;
27 }
28 } else if (n < -126) {
29 y *= 0x1p-126f * 0x1p24f;
30 n += 126 - 24;
31 if (n < -126) {
32 y *= 0x1p-126f * 0x1p24f;
33 n += 126 - 24;
34 if (n < -126)
35 n = -126;
36 }
37 }
38 u.i = (uint32_t)(0x7f+n)<<23;
39 x = y * u.f;
40 return x;
41}
#define uint32_t
Definition: nsiface.idl:61
float float_t
Definition: math.h:15

◆ sin()

Definition at line 21 of file sin.c.

22{
23 int quadrant;
24 double x2, result;
25
26 /* Calculate the quadrant */
27 quadrant = (int)(x * (2./M_PI));
28
29 /* Get offset inside quadrant */
30 x = x - quadrant * (M_PI/2.);
31
32 /* Normalize quadrant to [0..3] */
33 quadrant = (quadrant - 1) & 0x3;
34
35 /* Fixup value for the generic function */
36 x += sin_off_tbl[quadrant];
37
38 /* Calculate the negative of the square of x */
39 x2 = - (x * x);
40
41 /* This is an unrolled taylor series using <PRECISION> iterations
42 * Example with 4 iterations:
43 * result = 1 - x^2/2! + x^4/4! - x^6/6! + x^8/8!
44 * To save multiplications and to keep the precision high, it's performed
45 * like this:
46 * result = 1 - x^2 * (1/2! - x^2 * (1/4! - x^2 * (1/6! - x^2 * (1/8!))))
47 */
48
49 /* Start with 0, compiler will optimize this away */
50 result = 0;
51
52#if (PRECISION >= 10)
53 result += 1./(1.*2*3*4*5*6*7*8*9*10*11*12*13*14*15*16*17*18*19*20);
54 result *= x2;
55#endif
56#if (PRECISION >= 9)
57 result += 1./(1.*2*3*4*5*6*7*8*9*10*11*12*13*14*15*16*17*18);
58 result *= x2;
59#endif
60#if (PRECISION >= 8)
61 result += 1./(1.*2*3*4*5*6*7*8*9*10*11*12*13*14*15*16);
62 result *= x2;
63#endif
64#if (PRECISION >= 7)
65 result += 1./(1.*2*3*4*5*6*7*8*9*10*11*12*13*14);
66 result *= x2;
67#endif
68#if (PRECISION >= 6)
69 result += 1./(1.*2*3*4*5*6*7*8*9*10*11*12);
70 result *= x2;
71#endif
72#if (PRECISION >= 5)
73 result += 1./(1.*2*3*4*5*6*7*8*9*10);
74 result *= x2;
75#endif
76 result += 1./(1.*2*3*4*5*6*7*8);
77 result *= x2;
78
79 result += 1./(1.*2*3*4*5*6);
80 result *= x2;
81
82 result += 1./(1.*2*3*4);
83 result *= x2;
84
85 result += 1./(1.*2);
86 result *= x2;
87
88 result += 1;
89
90 /* Apply correct sign */
91 result *= sin_sign_tbl[quadrant];
92
93 return result;
94}
static double sin_off_tbl[]
Definition: sin.c:17
static double sin_sign_tbl[]
Definition: sin.c:18
#define M_PI
Definition: sin.c:15

Referenced by __libm_sse2_sin(), __libm_sse2_sinf(), __rpc_get_time_offset(), __rpc_sockisbound(), __rpc_taddr2uaddr_af(), __rpc_uaddr2taddr_af(), __sincos(), _CIsin(), _libm_sse2_sin_precise(), add_arc_part(), bindresvport(), bindresvport_sa(), compute_sincos_table(), D3DRMQuaternionFromRotation(), D3DRMQuaternionSlerp(), D3DRMVectorRotate(), draw_cap(), draw_graphics(), DrawGLScene(), EMFDRV_ArcChordPie(), expT(), GdipRotateMatrix(), get_server(), CAppScrnshotPreview::GetFrameDotShift(), gl_rotation_matrix(), Global_Sin(), gluPerspective(), init_layer3(), IntGdiAngleArc(), IntGdiWidenPath(), main(), Math_sin(), NetBTCall(), NetBTSendNameQuery(), netfinger(), CDrvDefExt::PaintStaticControls(), PATH_DoArcPart(), polar(), powT(), pres_sin(), RotatePoint(), rpc_broadcast_exp(), rpcrt4_ip_tcp_get_top_of_tower(), rpn_sin(), shorten_line_percent(), sincos(), sinf(), sinl(), Test_sin_approx(), Test_sin_exact(), TestKs(), ValarrayTest::transcendentals(), uaddr_to_sockaddr(), unstretch_angle(), wave_generate_la(), and wave_generate_tone().

◆ sinf()

◆ sinh()

Definition at line 50 of file sinh.c.

51{
52 /*
53 After dealing with special cases the computation is split into
54 regions as follows:
55
56 abs(x) >= max_sinh_arg:
57 sinh(x) = sign(x)*Inf
58
59 abs(x) >= small_threshold:
60 sinh(x) = sign(x)*exp(abs(x))/2 computed using the
61 splitexp and scaleDouble functions as for exp_amd().
62
63 abs(x) < small_threshold:
64 compute p = exp(y) - 1 and then z = 0.5*(p+(p/(p+1.0)))
65 sinh(x) is then sign(x)*z. */
66
67 static const double
68 max_sinh_arg = 7.10475860073943977113e+02, /* 0x408633ce8fb9f87e */
69 thirtytwo_by_log2 = 4.61662413084468283841e+01, /* 0x40471547652b82fe */
70 log2_by_32_lead = 2.16608493356034159660e-02, /* 0x3f962e42fe000000 */
71 log2_by_32_tail = 5.68948749532545630390e-11, /* 0x3dcf473de6af278e */
72 small_threshold = 8*BASEDIGITS_DP64*0.30102999566398119521373889;
73 /* (8*BASEDIGITS_DP64*log10of2) ' exp(-x) insignificant c.f. exp(x) */
74
75 /* Lead and tail tabulated values of sinh(i) and cosh(i)
76 for i = 0,...,36. The lead part has 26 leading bits. */
77
78 static const double sinh_lead[37] = {
79 0.00000000000000000000e+00, /* 0x0000000000000000 */
80 1.17520117759704589844e+00, /* 0x3ff2cd9fc0000000 */
81 3.62686038017272949219e+00, /* 0x400d03cf60000000 */
82 1.00178747177124023438e+01, /* 0x40240926e0000000 */
83 2.72899169921875000000e+01, /* 0x403b4a3800000000 */
84 7.42032089233398437500e+01, /* 0x40528d0160000000 */
85 2.01713153839111328125e+02, /* 0x406936d228000000 */
86 5.48316116333007812500e+02, /* 0x4081228768000000 */
87 1.49047882080078125000e+03, /* 0x409749ea50000000 */
88 4.05154187011718750000e+03, /* 0x40afa71570000000 */
89 1.10132326660156250000e+04, /* 0x40c5829dc8000000 */
90 2.99370708007812500000e+04, /* 0x40dd3c4488000000 */
91 8.13773945312500000000e+04, /* 0x40f3de1650000000 */
92 2.21206695312500000000e+05, /* 0x410b00b590000000 */
93 6.01302140625000000000e+05, /* 0x412259ac48000000 */
94 1.63450865625000000000e+06, /* 0x4138f0cca8000000 */
95 4.44305525000000000000e+06, /* 0x4150f2ebd0000000 */
96 1.20774762500000000000e+07, /* 0x4167093488000000 */
97 3.28299845000000000000e+07, /* 0x417f4f2208000000 */
98 8.92411500000000000000e+07, /* 0x419546d8f8000000 */
99 2.42582596000000000000e+08, /* 0x41aceb0888000000 */
100 6.59407856000000000000e+08, /* 0x41c3a6e1f8000000 */
101 1.79245641600000000000e+09, /* 0x41dab5adb8000000 */
102 4.87240166400000000000e+09, /* 0x41f226af30000000 */
103 1.32445608960000000000e+10, /* 0x4208ab7fb0000000 */
104 3.60024494080000000000e+10, /* 0x4220c3d390000000 */
105 9.78648043520000000000e+10, /* 0x4236c93268000000 */
106 2.66024116224000000000e+11, /* 0x424ef822f0000000 */
107 7.23128516608000000000e+11, /* 0x42650bba30000000 */
108 1.96566712320000000000e+12, /* 0x427c9aae40000000 */
109 5.34323724288000000000e+12, /* 0x4293704708000000 */
110 1.45244246507520000000e+13, /* 0x42aa6b7658000000 */
111 3.94814795284480000000e+13, /* 0x42c1f43fc8000000 */
112 1.07321789251584000000e+14, /* 0x42d866f348000000 */
113 2.91730863685632000000e+14, /* 0x42f0953e28000000 */
114 7.93006722514944000000e+14, /* 0x430689e220000000 */
115 2.15561576592179200000e+15}; /* 0x431ea215a0000000 */
116
117 static const double sinh_tail[37] = {
118 0.00000000000000000000e+00, /* 0x0000000000000000 */
119 1.60467555584448807892e-08, /* 0x3e513ae6096a0092 */
120 2.76742892754807136947e-08, /* 0x3e5db70cfb79a640 */
121 2.09697499555224576530e-07, /* 0x3e8c2526b66dc067 */
122 2.04940252448908240062e-07, /* 0x3e8b81b18647f380 */
123 1.65444891522700935932e-06, /* 0x3ebbc1cdd1e1eb08 */
124 3.53116789999998198721e-06, /* 0x3ecd9f201534fb09 */
125 6.94023870987375490695e-06, /* 0x3edd1c064a4e9954 */
126 4.98876893611587449271e-06, /* 0x3ed4eca65d06ea74 */
127 3.19656024605152215752e-05, /* 0x3f00c259bcc0ecc5 */
128 2.08687768377236501204e-04, /* 0x3f2b5a6647cf9016 */
129 4.84668088325403796299e-05, /* 0x3f09691adefb0870 */
130 1.17517985422733832468e-03, /* 0x3f53410fc29cde38 */
131 6.90830086959560562415e-04, /* 0x3f46a31a50b6fb3c */
132 1.45697262451506548420e-03, /* 0x3f57defc71805c40 */
133 2.99859023684906737806e-02, /* 0x3f9eb49fd80e0bab */
134 1.02538800507941396667e-02, /* 0x3f84fffc7bcd5920 */
135 1.26787628407699110022e-01, /* 0x3fc03a93b6c63435 */
136 6.86652479544033744752e-02, /* 0x3fb1940bb255fd1c */
137 4.81593627621056619148e-01, /* 0x3fded26e14260b50 */
138 1.70489513795397629181e+00, /* 0x3ffb47401fc9f2a2 */
139 1.12416073482258713767e+01, /* 0x40267bb3f55634f1 */
140 7.06579578070110514432e+00, /* 0x401c435ff8194ddc */
141 5.91244512999659974639e+01, /* 0x404d8fee052ba63a */
142 1.68921736147050694399e+02, /* 0x40651d7edccde3f6 */
143 2.60692936262073658327e+02, /* 0x40704b1644557d1a */
144 3.62419382134885609048e+02, /* 0x4076a6b5ca0a9dc4 */
145 4.07689930834187271103e+03, /* 0x40afd9cc72249aba */
146 1.55377375868385224749e+04, /* 0x40ce58de693edab5 */
147 2.53720210371943067003e+04, /* 0x40d8c70158ac6363 */
148 4.78822310734952334315e+04, /* 0x40e7614764f43e20 */
149 1.81871712615542812273e+05, /* 0x4106337db36fc718 */
150 5.62892347580489004031e+05, /* 0x41212d98b1f611e2 */
151 6.41374032312148716301e+05, /* 0x412392bc108b37cc */
152 7.57809544070145115256e+06, /* 0x415ce87bdc3473dc */
153 3.64177136406482197344e+06, /* 0x414bc8d5ae99ad14 */
154 7.63580561355670914054e+06}; /* 0x415d20d76744835c */
155
156 static const double cosh_lead[37] = {
157 1.00000000000000000000e+00, /* 0x3ff0000000000000 */
158 1.54308062791824340820e+00, /* 0x3ff8b07550000000 */
159 3.76219564676284790039e+00, /* 0x400e18fa08000000 */
160 1.00676617622375488281e+01, /* 0x402422a490000000 */
161 2.73082327842712402344e+01, /* 0x403b4ee858000000 */
162 7.42099475860595703125e+01, /* 0x40528d6fc8000000 */
163 2.01715633392333984375e+02, /* 0x406936e678000000 */
164 5.48317031860351562500e+02, /* 0x4081228948000000 */
165 1.49047915649414062500e+03, /* 0x409749eaa8000000 */
166 4.05154199218750000000e+03, /* 0x40afa71580000000 */
167 1.10132329101562500000e+04, /* 0x40c5829dd0000000 */
168 2.99370708007812500000e+04, /* 0x40dd3c4488000000 */
169 8.13773945312500000000e+04, /* 0x40f3de1650000000 */
170 2.21206695312500000000e+05, /* 0x410b00b590000000 */
171 6.01302140625000000000e+05, /* 0x412259ac48000000 */
172 1.63450865625000000000e+06, /* 0x4138f0cca8000000 */
173 4.44305525000000000000e+06, /* 0x4150f2ebd0000000 */
174 1.20774762500000000000e+07, /* 0x4167093488000000 */
175 3.28299845000000000000e+07, /* 0x417f4f2208000000 */
176 8.92411500000000000000e+07, /* 0x419546d8f8000000 */
177 2.42582596000000000000e+08, /* 0x41aceb0888000000 */
178 6.59407856000000000000e+08, /* 0x41c3a6e1f8000000 */
179 1.79245641600000000000e+09, /* 0x41dab5adb8000000 */
180 4.87240166400000000000e+09, /* 0x41f226af30000000 */
181 1.32445608960000000000e+10, /* 0x4208ab7fb0000000 */
182 3.60024494080000000000e+10, /* 0x4220c3d390000000 */
183 9.78648043520000000000e+10, /* 0x4236c93268000000 */
184 2.66024116224000000000e+11, /* 0x424ef822f0000000 */
185 7.23128516608000000000e+11, /* 0x42650bba30000000 */
186 1.96566712320000000000e+12, /* 0x427c9aae40000000 */
187 5.34323724288000000000e+12, /* 0x4293704708000000 */
188 1.45244246507520000000e+13, /* 0x42aa6b7658000000 */
189 3.94814795284480000000e+13, /* 0x42c1f43fc8000000 */
190 1.07321789251584000000e+14, /* 0x42d866f348000000 */
191 2.91730863685632000000e+14, /* 0x42f0953e28000000 */
192 7.93006722514944000000e+14, /* 0x430689e220000000 */
193 2.15561576592179200000e+15}; /* 0x431ea215a0000000 */
194
195 static const double cosh_tail[37] = {
196 0.00000000000000000000e+00, /* 0x0000000000000000 */
197 6.89700037027478056904e-09, /* 0x3e3d9f5504c2bd28 */
198 4.43207835591715833630e-08, /* 0x3e67cb66f0a4c9fd */
199 2.33540217013828929694e-07, /* 0x3e8f58617928e588 */
200 5.17452463948269748331e-08, /* 0x3e6bc7d000c38d48 */
201 9.38728274131605919153e-07, /* 0x3eaf7f9d4e329998 */
202 2.73012191010840495544e-06, /* 0x3ec6e6e464885269 */
203 3.29486051438996307950e-06, /* 0x3ecba3a8b946c154 */
204 4.75803746362771416375e-06, /* 0x3ed3f4e76110d5a4 */
205 3.33050940471947692369e-05, /* 0x3f017622515a3e2b */
206 9.94707313972136215365e-06, /* 0x3ee4dc4b528af3d0 */
207 6.51685096227860253398e-05, /* 0x3f11156278615e10 */
208 1.18132406658066663359e-03, /* 0x3f535ad50ed821f5 */
209 6.93090416366541877541e-04, /* 0x3f46b61055f2935c */
210 1.45780415323416845386e-03, /* 0x3f57e2794a601240 */
211 2.99862082708111758744e-02, /* 0x3f9eb4b45f6aadd3 */
212 1.02539925859688602072e-02, /* 0x3f85000b967b3698 */
213 1.26787669807076286421e-01, /* 0x3fc03a940fadc092 */
214 6.86652631843830962843e-02, /* 0x3fb1940bf3bf874c */
215 4.81593633223853068159e-01, /* 0x3fded26e1a2a2110 */
216 1.70489514001513020602e+00, /* 0x3ffb4740205796d6 */
217 1.12416073489841270572e+01, /* 0x40267bb3f55cb85d */
218 7.06579578098005001152e+00, /* 0x401c435ff81e18ac */
219 5.91244513000686140458e+01, /* 0x404d8fee052bdea4 */
220 1.68921736147088438429e+02, /* 0x40651d7edccde926 */
221 2.60692936262087528121e+02, /* 0x40704b1644557e0e */
222 3.62419382134890611269e+02, /* 0x4076a6b5ca0a9e1c */
223 4.07689930834187453002e+03, /* 0x40afd9cc72249abe */
224 1.55377375868385224749e+04, /* 0x40ce58de693edab5 */
225 2.53720210371943103382e+04, /* 0x40d8c70158ac6364 */
226 4.78822310734952334315e+04, /* 0x40e7614764f43e20 */
227 1.81871712615542812273e+05, /* 0x4106337db36fc718 */
228 5.62892347580489004031e+05, /* 0x41212d98b1f611e2 */
229 6.41374032312148716301e+05, /* 0x412392bc108b37cc */
230 7.57809544070145115256e+06, /* 0x415ce87bdc3473dc */
231 3.64177136406482197344e+06, /* 0x414bc8d5ae99ad14 */
232 7.63580561355670914054e+06}; /* 0x415d20d76744835c */
233
234 unsigned long long ux, aux, xneg;
235 double y, z, z1, z2;
236 int m;
237
238 /* Special cases */
239
240 GET_BITS_DP64(x, ux);
241 aux = ux & ~SIGNBIT_DP64;
242 if (aux < 0x3e30000000000000) /* |x| small enough that sinh(x) = x */
243 {
244 if (aux == 0)
245 /* with no inexact */
246 return x;
247 else
248 return val_with_flags(x, AMD_F_INEXACT);
249 }
250 else if (aux >= 0x7ff0000000000000) /* |x| is NaN or Inf */
251 {
252 if (aux > 0x7ff0000000000000)
253 /* x is NaN */
254 return _handle_error("sinh", OP_SINH, ux|0x0008000000000000, _DOMAIN,
255 0, EDOM, x, 0.0, 1);
256 else
257 return x + x;
258 }
259
260
261 xneg = (aux != ux);
262
263 y = x;
264 if (xneg) y = -x;
265
266 if (y >= max_sinh_arg)
267 {
268 if (xneg)
269 return _handle_error("sinh", OP_SINH, NINFBITPATT_DP64, _OVERFLOW,
270 AMD_F_OVERFLOW, ERANGE, x, 0.0, 1);
271 else
272 return _handle_error("sinh", OP_SINH, PINFBITPATT_DP64, _OVERFLOW,
273 AMD_F_OVERFLOW, ERANGE, x, 0.0, 1);
274 }
275 else if (y >= small_threshold)
276 {
277 /* In this range y is large enough so that
278 the negative exponential is negligible,
279 so sinh(y) is approximated by sign(x)*exp(y)/2. The
280 code below is an inlined version of that from
281 exp() with two changes (it operates on
282 y instead of x, and the division by 2 is
283 done by reducing m by 1). */
284
285 splitexp(y, 1.0, thirtytwo_by_log2, log2_by_32_lead,
286 log2_by_32_tail, &m, &z1, &z2);
287 m -= 1;
288
289 if (m >= EMIN_DP64 && m <= EMAX_DP64)
290 z = scaleDouble_1((z1+z2),m);
291 else
292 z = scaleDouble_2((z1+z2),m);
293 }
294 else
295 {
296 /* In this range we find the integer part y0 of y
297 and the increment dy = y - y0. We then compute
298
299 z = sinh(y) = sinh(y0)cosh(dy) + cosh(y0)sinh(dy)
300
301 where sinh(y0) and cosh(y0) are tabulated above. */
302
303 int ind;
304 double dy, dy2, sdy, cdy, sdy1, sdy2;
305
306 ind = (int)y;
307 dy = y - ind;
308
309 dy2 = dy*dy;
310 sdy = dy*dy2*(0.166666666666666667013899e0 +
311 (0.833333333333329931873097e-2 +
312 (0.198412698413242405162014e-3 +
313 (0.275573191913636406057211e-5 +
314 (0.250521176994133472333666e-7 +
315 (0.160576793121939886190847e-9 +
316 0.7746188980094184251527126e-12*dy2)*dy2)*dy2)*dy2)*dy2)*dy2);
317
318 cdy = dy2*(0.500000000000000005911074e0 +
319 (0.416666666666660876512776e-1 +
320 (0.138888888889814854814536e-2 +
321 (0.248015872460622433115785e-4 +
322 (0.275573350756016588011357e-6 +
323 (0.208744349831471353536305e-8 +
324 0.1163921388172173692062032e-10*dy2)*dy2)*dy2)*dy2)*dy2)*dy2);
325
326 /* At this point sinh(dy) is approximated by dy + sdy.
327 Shift some significant bits from dy to sdy. */
328
329 GET_BITS_DP64(dy, ux);
330 ux &= 0xfffffffff8000000;
331 PUT_BITS_DP64(ux, sdy1);
332 sdy2 = sdy + (dy - sdy1);
333
334 z = ((((((cosh_tail[ind]*sdy2 + sinh_tail[ind]*cdy)
335 + cosh_tail[ind]*sdy1) + sinh_tail[ind])
336 + cosh_lead[ind]*sdy2) + sinh_lead[ind]*cdy)
337 + cosh_lead[ind]*sdy1) + sinh_lead[ind];
338 }
339
340 if (xneg) z = - z;
341 return z;
342}
#define NINFBITPATT_DP64
Definition: libm_util.h:54
#define EMAX_DP64
Definition: libm_util.h:60
#define EMIN_DP64
Definition: libm_util.h:58

Referenced by _CIsinh(), rpn_sinh(), sinhf(), sinhl(), test_math_functions(), and ValarrayTest::transcendentals().

◆ sinhf()

_ACRTIMP float __cdecl sinhf ( float  fx)

Definition at line 51 of file sinhf.c.

52{
53 /*
54 After dealing with special cases the computation is split into
55 regions as follows:
56
57 abs(x) >= max_sinh_arg:
58 sinh(x) = sign(x)*Inf
59
60 abs(x) >= small_threshold:
61 sinh(x) = sign(x)*exp(abs(x))/2 computed using the
62 splitexp and scaleDouble functions as for exp_amd().
63
64 abs(x) < small_threshold:
65 compute p = exp(y) - 1 and then z = 0.5*(p+(p/(p+1.0)))
66 sinh(x) is then sign(x)*z. */
67
68 static const double
69 /* The max argument of sinhf, but stored as a double */
70 max_sinh_arg = 8.94159862922329438106e+01, /* 0x40565a9f84f82e63 */
71 thirtytwo_by_log2 = 4.61662413084468283841e+01, /* 0x40471547652b82fe */
72 log2_by_32_lead = 2.16608493356034159660e-02, /* 0x3f962e42fe000000 */
73 log2_by_32_tail = 5.68948749532545630390e-11, /* 0x3dcf473de6af278e */
74 small_threshold = 8*BASEDIGITS_DP64*0.30102999566398119521373889;
75 /* (8*BASEDIGITS_DP64*log10of2) ' exp(-x) insignificant c.f. exp(x) */
76
77 /* Tabulated values of sinh(i) and cosh(i) for i = 0,...,36. */
78
79 static const double sinh_lead[37] = {
80 0.00000000000000000000e+00, /* 0x0000000000000000 */
81 1.17520119364380137839e+00, /* 0x3ff2cd9fc44eb982 */
82 3.62686040784701857476e+00, /* 0x400d03cf63b6e19f */
83 1.00178749274099008204e+01, /* 0x40240926e70949ad */
84 2.72899171971277496596e+01, /* 0x403b4a3803703630 */
85 7.42032105777887522891e+01, /* 0x40528d0166f07374 */
86 2.01713157370279219549e+02, /* 0x406936d22f67c805 */
87 5.48316123273246489589e+02, /* 0x408122876ba380c9 */
88 1.49047882578955000099e+03, /* 0x409749ea514eca65 */
89 4.05154190208278987484e+03, /* 0x40afa7157430966f */
90 1.10132328747033916443e+04, /* 0x40c5829dced69991 */
91 2.99370708492480553105e+04, /* 0x40dd3c4488cb48d6 */
92 8.13773957064298447222e+04, /* 0x40f3de1654d043f0 */
93 2.21206696003330085659e+05, /* 0x410b00b5916a31a5 */
94 6.01302142081972560845e+05, /* 0x412259ac48bef7e3 */
95 1.63450868623590236530e+06, /* 0x4138f0ccafad27f6 */
96 4.44305526025387924165e+06, /* 0x4150f2ebd0a7ffe3 */
97 1.20774763767876271158e+07, /* 0x416709348c0ea4ed */
98 3.28299845686652474105e+07, /* 0x417f4f22091940bb */
99 8.92411504815936237574e+07, /* 0x419546d8f9ed26e1 */
100 2.42582597704895108938e+08, /* 0x41aceb088b68e803 */
101 6.59407867241607308388e+08, /* 0x41c3a6e1fd9eecfd */
102 1.79245642306579566002e+09, /* 0x41dab5adb9c435ff */
103 4.87240172312445068359e+09, /* 0x41f226af33b1fdc0 */
104 1.32445610649217357635e+10, /* 0x4208ab7fb5475fb7 */
105 3.60024496686929321289e+10, /* 0x4220c3d3920962c8 */
106 9.78648047144193725586e+10, /* 0x4236c932696a6b5c */
107 2.66024120300899291992e+11, /* 0x424ef822f7f6731c */
108 7.23128532145737548828e+11, /* 0x42650bba3796379a */
109 1.96566714857202099609e+12, /* 0x427c9aae4631c056 */
110 5.34323729076223046875e+12, /* 0x429370470aec28ec */
111 1.45244248326237109375e+13, /* 0x42aa6b765d8cdf6c */
112 3.94814800913403437500e+13, /* 0x42c1f43fcc4b662c */
113 1.07321789892958031250e+14, /* 0x42d866f34a725782 */
114 2.91730871263727437500e+14, /* 0x42f0953e2f3a1ef7 */
115 7.93006726156715250000e+14, /* 0x430689e221bc8d5a */
116 2.15561577355759750000e+15}; /* 0x431ea215a1d20d76 */
117
118 static const double cosh_lead[37] = {
119 1.00000000000000000000e+00, /* 0x3ff0000000000000 */
120 1.54308063481524371241e+00, /* 0x3ff8b07551d9f550 */
121 3.76219569108363138810e+00, /* 0x400e18fa0df2d9bc */
122 1.00676619957777653269e+01, /* 0x402422a497d6185e */
123 2.73082328360164865444e+01, /* 0x403b4ee858de3e80 */
124 7.42099485247878334349e+01, /* 0x40528d6fcbeff3a9 */
125 2.01715636122455890700e+02, /* 0x406936e67db9b919 */
126 5.48317035155212010977e+02, /* 0x4081228949ba3a8b */
127 1.49047916125217807348e+03, /* 0x409749eaa93f4e76 */
128 4.05154202549259389343e+03, /* 0x40afa715845d8894 */
129 1.10132329201033226127e+04, /* 0x40c5829dd053712d */
130 2.99370708659497577173e+04, /* 0x40dd3c4489115627 */
131 8.13773957125740562333e+04, /* 0x40f3de1654d6b543 */
132 2.21206696005590405548e+05, /* 0x410b00b5916b6105 */
133 6.01302142082804115489e+05, /* 0x412259ac48bf13ca */
134 1.63450868623620807193e+06, /* 0x4138f0ccafad2d17 */
135 4.44305526025399193168e+06, /* 0x4150f2ebd0a8005c */
136 1.20774763767876680940e+07, /* 0x416709348c0ea503 */
137 3.28299845686652623117e+07, /* 0x417f4f22091940bf */
138 8.92411504815936237574e+07, /* 0x419546d8f9ed26e1 */
139 2.42582597704895138741e+08, /* 0x41aceb088b68e804 */
140 6.59407867241607308388e+08, /* 0x41c3a6e1fd9eecfd */
141 1.79245642306579566002e+09, /* 0x41dab5adb9c435ff */
142 4.87240172312445068359e+09, /* 0x41f226af33b1fdc0 */
143 1.32445610649217357635e+10, /* 0x4208ab7fb5475fb7 */
144 3.60024496686929321289e+10, /* 0x4220c3d3920962c8 */
145 9.78648047144193725586e+10, /* 0x4236c932696a6b5c */
146 2.66024120300899291992e+11, /* 0x424ef822f7f6731c */
147 7.23128532145737548828e+11, /* 0x42650bba3796379a */
148 1.96566714857202099609e+12, /* 0x427c9aae4631c056 */
149 5.34323729076223046875e+12, /* 0x429370470aec28ec */
150 1.45244248326237109375e+13, /* 0x42aa6b765d8cdf6c */
151 3.94814800913403437500e+13, /* 0x42c1f43fcc4b662c */
152 1.07321789892958031250e+14, /* 0x42d866f34a725782 */
153 2.91730871263727437500e+14, /* 0x42f0953e2f3a1ef7 */
154 7.93006726156715250000e+14, /* 0x430689e221bc8d5a */
155 2.15561577355759750000e+15}; /* 0x431ea215a1d20d76 */
156
157 unsigned long long ux, aux, xneg;
158 double x = fx, y, z, z1, z2;
159 int m;
160
161 /* Special cases */
162
163 GET_BITS_DP64(x, ux);
164 aux = ux & ~SIGNBIT_DP64;
165 if (aux < 0x3f10000000000000) /* |x| small enough that sinh(x) = x */
166 {
167 if (aux == 0)
168 /* with no inexact */
169 return fx;
170 else
171 return valf_with_flags(fx, AMD_F_INEXACT);
172 }
173 else if (aux >= 0x7ff0000000000000) /* |x| is NaN or Inf */
174 {
175 if (aux > 0x7ff0000000000000)
176 {
177 /* x is NaN */
178 unsigned int uhx;
179 GET_BITS_SP32(fx, uhx);
180 return _handle_errorf("sinhf", OP_SINH, uhx|0x00400000, _DOMAIN,
181 0, EDOM, fx, 0.0F, 1);
182 }
183 else
184 return fx + fx;
185 }
186
187 xneg = (aux != ux);
188
189 y = x;
190 if (xneg) y = -x;
191
192 if (y >= max_sinh_arg)
193 {
194 /* Return infinity with overflow flag. */
195 if (xneg)
196 return _handle_errorf("sinhf", OP_SINH, NINFBITPATT_SP32, _OVERFLOW,
197 AMD_F_OVERFLOW, ERANGE, fx, 0.0F, 1);
198 else
199 return _handle_errorf("sinhf", OP_SINH, PINFBITPATT_SP32, _OVERFLOW,
200 AMD_F_OVERFLOW, ERANGE, fx, 0.0F, 1);
201 }
202 else if (y >= small_threshold)
203 {
204 /* In this range y is large enough so that
205 the negative exponential is negligible,
206 so sinh(y) is approximated by sign(x)*exp(y)/2. The
207 code below is an inlined version of that from
208 exp() with two changes (it operates on
209 y instead of x, and the division by 2 is
210 done by reducing m by 1). */
211
212 splitexp(y, 1.0, thirtytwo_by_log2, log2_by_32_lead,
213 log2_by_32_tail, &m, &z1, &z2);
214 m -= 1;
215 /* scaleDouble_1 is always safe because the argument x was
216 float, rather than double */
217 z = scaleDouble_1((z1+z2),m);
218 }
219 else
220 {
221 /* In this range we find the integer part y0 of y
222 and the increment dy = y - y0. We then compute
223
224 z = sinh(y) = sinh(y0)cosh(dy) + cosh(y0)sinh(dy)
225
226 where sinh(y0) and cosh(y0) are tabulated above. */
227
228 int ind;
229 double dy, dy2, sdy, cdy;
230
231 ind = (int)y;
232 dy = y - ind;
233
234 dy2 = dy*dy;
235
236 sdy = dy + dy*dy2*(0.166666666666666667013899e0 +
237 (0.833333333333329931873097e-2 +
238 (0.198412698413242405162014e-3 +
239 (0.275573191913636406057211e-5 +
240 (0.250521176994133472333666e-7 +
241 (0.160576793121939886190847e-9 +
242 0.7746188980094184251527126e-12*dy2)*dy2)*dy2)*dy2)*dy2)*dy2);
243
244 cdy = 1 + dy2*(0.500000000000000005911074e0 +
245 (0.416666666666660876512776e-1 +
246 (0.138888888889814854814536e-2 +
247 (0.248015872460622433115785e-4 +
248 (0.275573350756016588011357e-6 +
249 (0.208744349831471353536305e-8 +
250 0.1163921388172173692062032e-10*dy2)*dy2)*dy2)*dy2)*dy2)*dy2);
251
252 z = sinh_lead[ind]*cdy + cosh_lead[ind]*sdy;
253 }
254
255 if (xneg) z = - z;
256 return (float)z;
257}

Referenced by test_math_functions().

◆ sqrt()

Definition at line 5 of file sqrt.c.

7{
8 register union
9 {
10 __m128d x128d;
11 __m128i x128i;
12 } u ;
13 register union
14 {
15 unsigned long long ullx;
16 double dbl;
17 } u2;
18
19 /* Set the lower double-precision value of u to x.
20 All that we want, is that the compiler understands that we have the
21 function parameter in a register that we can address as an __m128.
22 Sadly there is no obvious way to do that. If we use the union, VS will
23 generate code to store xmm0 in memory and the read it into a GPR.
24 We avoid memory access by using a direct move. But even here we won't
25 get a simple MOVSD. We can either do:
26 a) _mm_set_sd: move x into the lower part of an xmm register and zero
27 out the upper part (XORPD+MOVSD)
28 b) _mm_set1_pd: move x into the lower and higher part of an xmm register
29 (MOVSD+UNPCKLPD)
30 c) _mm_set_pd, which either generates a memory access, when we try to
31 tell it to keep the upper 64 bits, or generate 2 MOVAPS + UNPCKLPD
32 We choose a, which is probably the fastest.
33 */
34 u.x128d = _mm_set_sd(x);
35
36 /* Move the contents of the lower 64 bit into a 64 bit GPR using MOVD */
37 u2.ullx = _mm_cvtsi128_si64(u.x128i);
38
39 /* Check for negative values */
40 if (u2.ullx & 0x8000000000000000ULL)
41 {
42 /* Check if this is *really* negative and not just -0.0 */
43 if (u2.ullx != 0x8000000000000000ULL)
44 {
45 /* Return -1.#IND00 */
46 u2.ullx = 0xfff8000000000000ULL;
47 }
48
49 /* Return what we have */
50 return u2.dbl;
51 }
52
53 /* Check if this is a NaN (bits 52-62 are 1, bit 0-61 are not all 0) or
54 negative (bit 63 is 1) */
55 if (u2.ullx > 0x7FF0000000000000ULL)
56 {
57 /* Set this bit. That's what MS function does. */
58 u2.ullx |= 0x8000000000000ULL;
59 return u2.dbl;
60 }
61
62 /* Calculate the square root. */
63#ifdef _MSC_VER
64 /* Another YAY for the MS compiler. There are 2 instructions we could use:
65 SQRTPD (computes sqrt for 2 double values) or SQRTSD (computes sqrt for
66 only the lower 64 bit double value). Obviously we only need 1. And on
67 Some architectures SQRTPD is twice as slow as SQRTSD. On the other hand
68 the MS compiler is stupid and always generates an additional MOVAPS
69 instruction when SQRTSD is used. We choose to use SQRTPD here since on
70 modern hardware it's as fast as SQRTSD. */
71 u.x128d = _mm_sqrt_pd(u.x128d); // SQRTPD
72#else
73 u.x128d = _mm_sqrt_sd(u.x128d, u.x128d); // SQRTSD
74#endif
75
76 return u.x128d.m128d_f64[0];
77}
__m128d _mm_set_sd(double w)
Definition: emmintrin.h:1037
__INTRIN_INLINE_SSE2 long long _mm_cvtsi128_si64(__m128i a)
Definition: emmintrin.h:1551
__m128d _mm_sqrt_pd(__m128d a)
Definition: emmintrin.h:626

Referenced by __ieee754_sqrt(), _cabs(), _CIsqrt(), _hypot(), _libm_sse2_sqrt_precise(), _y0(), _y1(), _yn(), acos(), acosh(), asin(), asinh(), atanh(), bezier_deviation_squared(), D3DRMVectorModulus(), D3DXBoundProbeTest(), D3DXMatrixTest(), D3DXPlaneTest(), draw_cap(), NS1::f(), anonymous_namespace{resolve_name.cpp}::g(), GdipDrawString(), GdipGetLogFontW(), GdipMeasureCharacterRanges(), GdipMeasureDriverString(), GdipMeasureString(), GdipSetLineSigmaBlend(), GdipSetPathGradientSigmaBlend(), get_font_hfont(), CAppScrnshotPreview::GetFrameDotShift(), gl_sqrt(), Global_Sqr(), h(), OpenGLSurfaceEvaluator::inComputeNormal2(), init_layer3(), init_sqrt(), IntGdiWidenPath(), Math_sqrt(), normalize(), prepare_dc(), pres_rsq(), rpn_s_ex(), rpn_sqrt(), shorten_bezier_amt(), shorten_line_amt(), shorten_line_percent(), SOFTWARE_GdipDrawPath(), sq::sqroot(), sqrtf(), sqrtl(), test_printf_fp(), test_sprintf(), Test_sqrt_approx(), Test_sqrt_exact(), test_timer(), ValarrayTest::transcendentals(), VectorMagnitude(), and CardRegion::ZoomCard().

◆ sqrtf()

_ACRTIMP float __cdecl sqrtf ( float  x)

This file has no copyright assigned and is placed in the Public Domain. This file is part of the w64 mingw-runtime package. No warranty is given; refer to the file DISCLAIMER.PD within this package.

Definition at line 9 of file sqrtf.c.

10{
11 return ((float)sqrt((double)x));
12}

◆ tan()

Definition at line 122 of file tan.c.

123{
124 double r, rr;
125 int region, xneg;
126
127 unsigned long long ux, ax;
128 GET_BITS_DP64(x, ux);
129 ax = (ux & ~SIGNBIT_DP64);
130 if (ax <= 0x3fe921fb54442d18) /* abs(x) <= pi/4 */
131 {
132 if (ax < 0x3f20000000000000) /* abs(x) < 2.0^(-13) */
133 {
134 if (ax < 0x3e40000000000000) /* abs(x) < 2.0^(-27) */
135 {
136 if (ax == 0x0000000000000000) return x;
137 else return val_with_flags(x, AMD_F_INEXACT);
138 }
139 else
140 {
141 /* Using a temporary variable prevents 64-bit VC++ from
142 rearranging
143 x + x*x*x*0.333333333333333333;
144 into
145 x * (1 + x*x*0.333333333333333333);
146 The latter results in an incorrectly rounded answer. */
147 double tmp;
148 tmp = x*x*x*0.333333333333333333;
149 return x + tmp;
150 }
151 }
152 else
153 return tan_piby4(x, 0.0, 0);
154 }
155 else if ((ux & EXPBITS_DP64) == EXPBITS_DP64)
156 {
157 /* x is either NaN or infinity */
158 if (ux & MANTBITS_DP64)
159 /* x is NaN */
160 return _handle_error("tan", OP_TAN, ux|0x0008000000000000, _DOMAIN, 0,
161 EDOM, x, 0.0, 1);
162 else
163 /* x is infinity. Return a NaN */
165 EDOM, x, 0.0, 1);
166 }
167 xneg = (ax != ux);
168
169
170 if (xneg)
171 x = -x;
172
173 if (x < 5.0e5)
174 {
175 /* For these size arguments we can just carefully subtract the
176 appropriate multiple of pi/2, using extra precision where
177 x is close to an exact multiple of pi/2 */
178 static const double
179 twobypi = 6.36619772367581382433e-01, /* 0x3fe45f306dc9c883 */
180 piby2_1 = 1.57079632673412561417e+00, /* 0x3ff921fb54400000 */
181 piby2_1tail = 6.07710050650619224932e-11, /* 0x3dd0b4611a626331 */
182 piby2_2 = 6.07710050630396597660e-11, /* 0x3dd0b4611a600000 */
183 piby2_2tail = 2.02226624879595063154e-21, /* 0x3ba3198a2e037073 */
184 piby2_3 = 2.02226624871116645580e-21, /* 0x3ba3198a2e000000 */
185 piby2_3tail = 8.47842766036889956997e-32; /* 0x397b839a252049c1 */
186 double t, rhead, rtail;
187 int npi2;
188 unsigned long long uy, xexp, expdiff;
189 xexp = ax >> EXPSHIFTBITS_DP64;
190 /* How many pi/2 is x a multiple of? */
191 if (ax <= 0x400f6a7a2955385e) /* 5pi/4 */
192 {
193 if (ax <= 0x4002d97c7f3321d2) /* 3pi/4 */
194 npi2 = 1;
195 else
196 npi2 = 2;
197 }
198 else if (ax <= 0x401c463abeccb2bb) /* 9pi/4 */
199 {
200 if (ax <= 0x4015fdbbe9bba775) /* 7pi/4 */
201 npi2 = 3;
202 else
203 npi2 = 4;
204 }
205 else
206 npi2 = (int)(x * twobypi + 0.5);
207 /* Subtract the multiple from x to get an extra-precision remainder */
208 rhead = x - npi2 * piby2_1;
209 rtail = npi2 * piby2_1tail;
210 GET_BITS_DP64(rhead, uy);
211 expdiff = xexp - ((uy & EXPBITS_DP64) >> EXPSHIFTBITS_DP64);
212 if (expdiff > 15)
213 {
214 /* The remainder is pretty small compared with x, which
215 implies that x is a near multiple of pi/2
216 (x matches the multiple to at least 15 bits) */
217 t = rhead;
218 rtail = npi2 * piby2_2;
219 rhead = t - rtail;
220 rtail = npi2 * piby2_2tail - ((t - rhead) - rtail);
221 if (expdiff > 48)
222 {
223 /* x matches a pi/2 multiple to at least 48 bits */
224 t = rhead;
225 rtail = npi2 * piby2_3;
226 rhead = t - rtail;
227 rtail = npi2 * piby2_3tail - ((t - rhead) - rtail);
228 }
229 }
230 r = rhead - rtail;
231 rr = (rhead - r) - rtail;
232 region = npi2 & 3;
233 }
234 else
235 {
236 /* Reduce x into range [-pi/4,pi/4] */
237 __remainder_piby2(x, &r, &rr, &region);
238 }
239
240 if (xneg)
241 return -tan_piby4(r, rr, region & 1);
242 else
243 return tan_piby4(r, rr, region & 1);
244}
void __remainder_piby2(double x, double *r, double *rr, int *region)
static double tan_piby4(double x, double xx, int recip)
Definition: tan.c:42

Referenced by __libm_sse2_tan(), __libm_sse2_tanf(), _CItan(), _libm_sse2_tan_precise(), app_boundary_point(), GdipCreateLineBrushFromRectWithAngle(), Global_Tan(), init_layer3(), Math_tan(), rpn_tan(), SkewDIB(), tanf(), tanl(), Test_tan_approx(), Test_tan_exact(), and ValarrayTest::transcendentals().

◆ tanf()

_ACRTIMP float __cdecl tanf ( float  x)

Definition at line 72 of file tanf.c.

73{
74 double r, dx;
75 int region, xneg;
76
77 unsigned long long ux, ax;
78
79 dx = x;
80
81 GET_BITS_DP64(dx, ux);
82 ax = (ux & ~SIGNBIT_DP64);
83
84 if (ax <= 0x3fe921fb54442d18) /* abs(x) <= pi/4 */
85 {
86 if (ax < 0x3f80000000000000) /* abs(x) < 2.0^(-7) */
87 {
88 if (ax < 0x3f20000000000000) /* abs(x) < 2.0^(-13) */
89 {
90 if (ax == 0x0000000000000000)
91 return x;
92 else
93 return valf_with_flags(x, AMD_F_INEXACT);
94 }
95 else
96 return (float)(dx + dx*dx*dx*0.333333333333333333);
97 }
98 else
99 return (float)tanf_piby4(x, 0);
100 }
101 else if ((ux & EXPBITS_DP64) == EXPBITS_DP64)
102 {
103 /* x is either NaN or infinity */
104 if (ux & MANTBITS_DP64)
105 {
106 /* x is NaN */
107 unsigned int ufx;
108 GET_BITS_SP32(x, ufx);
109 return _handle_errorf("tanf", OP_TAN, ufx|0x00400000, _DOMAIN, 0,
110 EDOM, x, 0.0F, 1);
111 }
112 else
113 {
114 /* x is infinity. Return a NaN */
115 return _handle_errorf("tanf", OP_TAN, INDEFBITPATT_SP32, _DOMAIN, AMD_F_INVALID,
116 EDOM, x, 0.0F, 1);
117 }
118 }
119
120 xneg = (int)(ux >> 63);
121
122 if (xneg)
123 dx = -dx;
124
125 if (dx < 5.0e5)
126 {
127 /* For these size arguments we can just carefully subtract the
128 appropriate multiple of pi/2, using extra precision where
129 dx is close to an exact multiple of pi/2 */
130 static const double
131 twobypi = 6.36619772367581382433e-01, /* 0x3fe45f306dc9c883 */
132 piby2_1 = 1.57079632673412561417e+00, /* 0x3ff921fb54400000 */
133 piby2_1tail = 6.07710050650619224932e-11, /* 0x3dd0b4611a626331 */
134 piby2_2 = 6.07710050630396597660e-11, /* 0x3dd0b4611a600000 */
135 piby2_2tail = 2.02226624879595063154e-21, /* 0x3ba3198a2e037073 */
136 piby2_3 = 2.02226624871116645580e-21, /* 0x3ba3198a2e000000 */
137 piby2_3tail = 8.47842766036889956997e-32; /* 0x397b839a252049c1 */
138 double t, rhead, rtail;
139 int npi2;
140 unsigned long long uy, xexp, expdiff;
141 xexp = ax >> EXPSHIFTBITS_DP64;
142 /* How many pi/2 is dx a multiple of? */
143 if (ax <= 0x400f6a7a2955385e) /* 5pi/4 */
144 {
145 if (ax <= 0x4002d97c7f3321d2) /* 3pi/4 */
146 npi2 = 1;
147 else
148 npi2 = 2;
149 }
150 else if (ax <= 0x401c463abeccb2bb) /* 9pi/4 */
151 {
152 if (ax <= 0x4015fdbbe9bba775) /* 7pi/4 */
153 npi2 = 3;
154 else
155 npi2 = 4;
156 }
157 else
158 npi2 = (int)(dx * twobypi + 0.5);
159 /* Subtract the multiple from dx to get an extra-precision remainder */
160 rhead = dx - npi2 * piby2_1;
161 rtail = npi2 * piby2_1tail;
162 GET_BITS_DP64(rhead, uy);
163 expdiff = xexp - ((uy & EXPBITS_DP64) >> EXPSHIFTBITS_DP64);
164 if (expdiff > 15)
165 {
166 /* The remainder is pretty small compared with dx, which
167 implies that dx is a near multiple of pi/2
168 (dx matches the multiple to at least 15 bits) */
169 t = rhead;
170 rtail = npi2 * piby2_2;
171 rhead = t - rtail;
172 rtail = npi2 * piby2_2tail - ((t - rhead) - rtail);
173 if (expdiff > 48)
174 {
175 /* dx matches a pi/2 multiple to at least 48 bits */
176 t = rhead;
177 rtail = npi2 * piby2_3;
178 rhead = t - rtail;
179 rtail = npi2 * piby2_3tail - ((t - rhead) - rtail);
180 }
181 }
182 r = rhead - rtail;
183 region = npi2 & 3;
184 }
185 else
186 {
187 /* Reduce x into range [-pi/4,pi/4] */
188 __remainder_piby2f_inline(ax, &r, &region);
189 }
190
191 if (xneg)
192 return (float)-tanf_piby4(r, region & 1);
193 else
194 return (float)tanf_piby4(r, region & 1);
195}
static double tanf_piby4(double x, int recip)
Definition: tanf.c:51

Referenced by D3DXMatrixPerspectiveFovLH(), D3DXMatrixPerspectiveFovRH(), Test_tanf_approx(), and Test_tanf_exact().

◆ tanh()

Definition at line 46 of file tanh.c.

47{
48 /*
49 The definition of tanh(x) is sinh(x)/cosh(x), which is also equivalent
50 to the following three formulae:
51 1. (exp(x) - exp(-x))/(exp(x) + exp(-x))
52 2. (1 - (2/(exp(2*x) + 1 )))
53 3. (exp(2*x) - 1)/(exp(2*x) + 1)
54 but computationally, some formulae are better on some ranges.
55 */
56 static const double
57 thirtytwo_by_log2 = 4.61662413084468283841e+01, /* 0x40471547652b82fe */
58 log2_by_32_lead = 2.16608493356034159660e-02, /* 0x3f962e42fe000000 */
59 log2_by_32_tail = 5.68948749532545630390e-11, /* 0x3dcf473de6af278e */
60 large_threshold = 20.0; /* 0x4034000000000000 */
61
62 unsigned long long ux, aux, xneg;
63 double y, z, p, z1, z2;
64 int m;
65
66 /* Special cases */
67
68 GET_BITS_DP64(x, ux);
69 aux = ux & ~SIGNBIT_DP64;
70 if (aux < 0x3e30000000000000) /* |x| small enough that tanh(x) = x */
71 {
72 if (aux == 0)
73 return x; /* with no inexact */
74 else
75 return val_with_flags(x, AMD_F_INEXACT);
76 }
77 else if (aux > 0x7ff0000000000000) /* |x| is NaN */
78 return _handle_error("tanh", OP_TANH, ux|0x0008000000000000, _DOMAIN,
79 0, EDOM, x, 0.0, 1);
80// return x + x;
81
82 xneg = (aux != ux);
83
84 y = x;
85 if (xneg) y = -x;
86
87 if (y > large_threshold)
88 {
89 /* If x is large then exp(-x) is negligible and
90 formula 1 reduces to plus or minus 1.0 */
91 z = 1.0;
92 }
93 else if (y <= 1.0)
94 {
95 double y2;
96 y2 = y*y;
97 if (y < 0.9)
98 {
99 /* Use a [3,3] Remez approximation on [0,0.9]. */
100 z = y + y*y2*
101 (-0.274030424656179760118928e0 +
102 (-0.176016349003044679402273e-1 +
103 (-0.200047621071909498730453e-3 -
104 0.142077926378834722618091e-7*y2)*y2)*y2)/
105 (0.822091273968539282568011e0 +
106 (0.381641414288328849317962e0 +
107 (0.201562166026937652780575e-1 +
108 0.2091140262529164482568557e-3*y2)*y2)*y2);
109 }
110 else
111 {
112 /* Use a [3,3] Remez approximation on [0.9,1]. */
113 z = y + y*y2*
114 (-0.227793870659088295252442e0 +
115 (-0.146173047288731678404066e-1 +
116 (-0.165597043903549960486816e-3 -
117 0.115475878996143396378318e-7*y2)*y2)*y2)/
118 (0.683381611977295894959554e0 +
119 (0.317204558977294374244770e0 +
120 (0.167358775461896562588695e-1 +
121 0.173076050126225961768710e-3*y2)*y2)*y2);
122 }
123 }
124 else
125 {
126 /* Compute p = exp(2*y) + 1. The code is basically inlined
127 from exp_amd. */
128
129 splitexp(2*y, 1.0, thirtytwo_by_log2, log2_by_32_lead,
130 log2_by_32_tail, &m, &z1, &z2);
131 p = scaleDouble_2(z1 + z2, m) + 1.0;
132
133 /* Now reconstruct tanh from p. */
134 z = (1.0 - 2.0/p);
135 }
136
137 if (xneg) z = - z;
138 return z;
139}
_In_ CLIPOBJ _In_ BRUSHOBJ _In_ LONG _In_ LONG _In_ LONG _In_ LONG y2
Definition: winddi.h:3711

Referenced by _CItanh(), MSVCRT_tanh(), rpn_tanh(), tanhf(), tanhl(), test_math_functions(), and ValarrayTest::transcendentals().

◆ tanhf()

_ACRTIMP float __cdecl tanhf ( float  x)

Definition at line 49 of file tanhf.c.

50{
51 /*
52 The definition of tanh(x) is sinh(x)/cosh(x), which is also equivalent
53 to the following three formulae:
54 1. (exp(x) - exp(-x))/(exp(x) + exp(-x))
55 2. (1 - (2/(exp(2*x) + 1 )))
56 3. (exp(2*x) - 1)/(exp(2*x) + 1)
57 but computationally, some formulae are better on some ranges.
58 */
59 static const float
60 thirtytwo_by_log2 = 4.6166240692e+01F, /* 0x4238aa3b */
61 log2_by_32_lead = 2.1659851074e-02F, /* 0x3cb17000 */
62 log2_by_32_tail = 9.9831822808e-07F, /* 0x3585fdf4 */
63 large_threshold = 10.0F; /* 0x41200000 */
64
65 unsigned int ux, aux;
66 float y, z, p, z1, z2, xneg;
67 int m;
68
69 /* Special cases */
70
71 GET_BITS_SP32(x, ux);
72 aux = ux & ~SIGNBIT_SP32;
73 if (aux < 0x39000000) /* |x| small enough that tanh(x) = x */
74 {
75 if (aux == 0)
76 return x; /* with no inexact */
77 else
78 return valf_with_flags(x, AMD_F_INEXACT);
79 }
80 else if (aux > 0x7f800000) /* |x| is NaN */
81 {
82 unsigned int ufx;
83 GET_BITS_SP32(x, ufx);
84 return _handle_errorf("tanhf", OP_TANH, ufx|0x00400000, _DOMAIN, 0,
85 EDOM, x, 0.0F, 1);
86 }
87// return x + x;
88
89 xneg = 1.0F - 2.0F * (aux != ux);
90
91 y = xneg * x;
92
93 if (y > large_threshold)
94 {
95 /* If x is large then exp(-x) is negligible and
96 formula 1 reduces to plus or minus 1.0 */
97 z = 1.0F;
98 }
99 else if (y <= 1.0F)
100 {
101 float y2;
102 y2 = y*y;
103
104 if (y < 0.9F)
105 {
106 /* Use a [2,1] Remez approximation on [0,0.9]. */
107 z = y + y*y2*
108 (-0.28192806108402678e0F +
109 (-0.14628356048797849e-2F +
110 0.4891631088530669873e-4F*y2)*y2)/
111 (0.845784192581041099e0F +
112 0.3427017942262751343e0F*y2);
113 }
114 else
115 {
116 /* Use a [2,1] Remez approximation on [0.9,1]. */
117 z = y + y*y2*
118 (-0.24069858695196524e0F +
119 (-0.12325644183611929e-2F +
120 0.3827534993599483396e-4F*y2)*y2)/
121 (0.72209738473684982e0F +
122 0.292529068698052819e0F*y2);
123 }
124 }
125 else
126 {
127 /* Compute p = exp(2*y) + 1. The code is basically inlined
128 from exp_amd. */
129
130 splitexpf(2*y, 1.0F, thirtytwo_by_log2, log2_by_32_lead,
131 log2_by_32_tail, &m, &z1, &z2);
132 p = scaleFloat_2(z1 + z2, m) + 1.0F;
133 /* Now reconstruct tanh from p. */
134 z = (1.0F - 2.0F/p);
135 }
136
137 return xneg * z;
138}

Referenced by MSVCRT_tanhf(), and test_math_functions().

◆ tgamma()

_ACRTIMP double __cdecl tgamma ( double  )

◆ tgammaf()

_ACRTIMP float __cdecl tgammaf ( float  )

◆ trunc()

Referenced by divide_ext().

◆ truncf()

_ACRTIMP float __cdecl truncf ( float  )

◆ y0()

static double y0 ( double  x)
inlinestatic

Definition at line 424 of file math.h.

424{ return _y0( x ); }
_ACRTIMP double __cdecl _y0(double)
Definition: j0_y0.c:19

◆ y1()

static double y1 ( double  x)
inlinestatic

Definition at line 425 of file math.h.

425{ return _y1( x ); }
_ACRTIMP double __cdecl _y1(double)
Definition: j1_y1.c:19

◆ yn()

static double yn ( int  n,
double  x 
)
inlinestatic

Definition at line 426 of file math.h.

426{ return _yn( n, x ); }
_ACRTIMP double __cdecl _yn(int, double)
Definition: jn_yn.c:21

Variable Documentation

◆ __f

float __f

Definition at line 270 of file math.h.

Referenced by __construct_checker< _Container >::__construct_checker(), __do_put_bool(), __do_put_float(), __do_put_integer(), __DOUBLE_BITS(), __FLOAT_BITS(), __get_money_digits(), __get_money_digits_aux(), __put_float(), __put_integer(), __stlp_string_fill(), _FILE_fd(), basic_string< _CharT, _Traits, _Alloc >::_M_assign(), _Rope_RopeRep< _CharT, _Alloc >::_M_free_tree(), vector< _Tp, >::_M_set(), _Rope_fill(), _S_apply_to_pieces(), rope< _CharT, _Alloc >::_S_fetch(), rope< _CharT, _Alloc >::_S_flatten(), rope< _CharT, _Alloc >::_S_new_RopeFunction(), rope< _CharT, _Alloc >::_S_substring(), valarray< _Tp >::apply(), num_put< _CharT, _OutputIter >::do_put(), time_put< _Ch, _OutIt >::do_put(), unordered_map< _Key, _Tp,,, >::erase(), unordered_multimap< _Key, _Tp,,, >::erase(), unordered_set< _Value,,, >::erase(), unordered_multiset< _Value,,, >::erase(), hash_map< _Key, _Tp,,, >::erase(), hash_multimap< _Key, _Tp,,, >::erase(), hash_set< _Value,,, >::erase(), hash_multiset< _Value,,, >::erase(), for_each(), hash_map< _Key, _Tp,,, >::hash_map(), hash_multimap< _Key, _Tp,,, >::hash_multimap(), hash_multiset< _Value,,, >::hash_multiset(), hash_set< _Value,,, >::hash_set(), hash_map< _Key, _Tp,,, >::insert(), hash_multimap< _Key, _Tp,,, >::insert(), hash_multiset< _Value,,, >::insert(), unordered_map< _Key, _Tp,,, >::insert(), unordered_multimap< _Key, _Tp,,, >::insert(), unordered_multiset< _Value,,, >::insert(), hash_set< _Value,,, >::insert(), unordered_set< _Value,,, >::insert(), hashtable< _Val, _Key, _HF, _Traits, _ExK, _EqK, _All >::insert_equal(), hashtable< _Val, _Key, _HF, _Traits, _ExK, _EqK, _All >::insert_unique(), locale::locale(), mem_fun(), mem_fun1(), mem_fun1_ref(), mem_fun_ref(), basic_ostream< _CharT, _Traits >::operator<<(), operator<<(), basic_istream< _CharT, _Traits >::operator>>(), operator>>(), ptr_fun(), time_put< _Ch, _OutIt >::put(), num_put< _CharT, _OutputIter >::put(), __malloc_alloc::set_malloc_handler(), setprecision(), setw(), unordered_map< _Key, _Tp,,, >::unordered_map(), unordered_multimap< _Key, _Tp,,, >::unordered_multimap(), unordered_multiset< _Value,,, >::unordered_multiset(), and unordered_set< _Value,,, >::unordered_set().

◆ __i

Definition at line 269 of file math.h.

Referenced by __advance(), __DOUBLE_BITS(), __FLOAT_BITS(), __insertion_sort(), __match(), __money_do_get(), __money_do_put(), __mutable_reference_at(), __next_permutation(), __partial_sort(), __prev_permutation(), __rotate_aux(), __search_n(), __stl_string_hash(), __stlp_string_fill(), __unguarded_insertion_sort_aux(), _CArray< _Tp, _Nb >::_CArray(), _Bit_iterator_base::_M_advance(), bitset< _Nb >::_M_copy_from_string(), bitset< _Nb >::_M_copy_to_string(), _Base_bitset< _Nw >::_M_do_and(), _Base_bitset< _Nw >::_M_do_find_first(), _Base_bitset< _Nw >::_M_do_find_next(), _Base_bitset< _Nw >::_M_do_flip(), _Base_bitset< _Nw >::_M_do_or(), _Base_bitset< _Nw >::_M_do_set(), _Base_bitset< _Nw >::_M_do_to_ulong(), _Base_bitset< _Nw >::_M_do_xor(), vector< _Tp, >::_M_erase(), list< _Tp, >::_M_fill_assign(), deque< wstring >::_M_fill_insert(), __BVECTOR_QUALIFIED::_M_fill_insert(), subtractive_rng::_M_initialize(), slist< _Tp, >::_M_insert_after_fill(), __BVECTOR_QUALIFIED::_M_insert_aux(), _Base_bitset< _Nw >::_M_is_any(), _Base_bitset< _Nw >::_M_is_equal(), deque< _Tp, >::_M_new_elements_at_front(), mask_array< _Tp >::_M_num_true(), _Rope_fill(), rope< _CharT, _Alloc >::_S_add_leaf_to_forest(), rope< _CharT, _Alloc >::_S_balance(), __node_alloc_impl::_S_chunk_alloc(), rope< _CharT, _Alloc >::_S_fetch(), rope< _CharT, _Alloc >::_S_fetch_ptr(), _Rope_iterator_base< _CharT, _Alloc >::_S_setcache(), _Rope_iterator_base< _CharT, _Alloc >::_S_setcache_for_incr(), _Slist_sort(), abs(), acos(), advance(), sequence_buffer< _Sequence, _Buf_sz >::append(), asin(), __char_traits_base< _CharT, _IntT >::assign(), atan(), atan2(), binary_search(), __char_traits_base< _CharT, _IntT >::compare(), cos(), cosh(), istreambuf_iterator< _CharT, _Traits >::equal(), _Rb_tree< _Key, _Compare, _Value, _KeyOfValue, _Traits, >::erase_unique(), exp(), __BVECTOR_QUALIFIED::insert(), rope< _CharT, _Alloc >::insert(), inserter(), __char_traits_base< _CharT, _IntT >::length(), log(), log10(), modfl(), valarray< _Tp >::operator!(), operator!=(), operator%(), slice_array< _Tp >::operator%=(), gslice_array< _Tp >::operator%=(), mask_array< _Tp >::operator%=(), indirect_array< _Tp >::operator%=(), valarray< _Tp >::operator%=(), operator&(), operator&&(), slice_array< _Tp >::operator&=(), gslice_array< _Tp >::operator&=(), mask_array< _Tp >::operator&=(), indirect_array< _Tp >::operator&=(), valarray< _Tp >::operator&=(), _Rope_find_char_char_consumer< _CharT >::operator()(), _Rope_insert_char_consumer< _CharT, _Traits >::operator()(), operator*(), complex< _Tp >::operator*=(), complex< float >::operator*=(), complex< double >::operator*=(), complex< long double >::operator*=(), slice_array< _Tp >::operator*=(), gslice_array< _Tp >::operator*=(), mask_array< _Tp >::operator*=(), indirect_array< _Tp >::operator*=(), valarray< _Tp >::operator*=(), operator+(), _Bit_iter< _Ref, _Ptr >::operator+(), slice_array< _Tp >::operator+=(), gslice_array< _Tp >::operator+=(), mask_array< _Tp >::operator+=(), indirect_array< _Tp >::operator+=(), valarray< _Tp >::operator+=(), _Bit_iter< _Ref, _Ptr >::operator+=(), valarray< _Tp >::operator-(), operator-(), _Bit_iter< _Ref, _Ptr >::operator-(), slice_array< _Tp >::operator-=(), gslice_array< _Tp >::operator-=(), mask_array< _Tp >::operator-=(), indirect_array< _Tp >::operator-=(), valarray< _Tp >::operator-=(), _Bit_iter< _Ref, _Ptr >::operator-=(), operator/(), complex< _Tp >::operator/=(), complex< float >::operator/=(), complex< double >::operator/=(), complex< long double >::operator/=(), slice_array< _Tp >::operator/=(), gslice_array< _Tp >::operator/=(), mask_array< _Tp >::operator/=(), indirect_array< _Tp >::operator/=(), valarray< _Tp >::operator/=(), operator<(), operator<<(), slice_array< _Tp >::operator<<=(), gslice_array< _Tp >::operator<<=(), mask_array< _Tp >::operator<<=(), indirect_array< _Tp >::operator<<=(), valarray< _Tp >::operator<<=(), operator<=(), vector< _Tp, >::operator=(), valarray< _Tp >::operator=(), slice_array< _Tp >::operator=(), gslice_array< _Tp >::operator=(), mask_array< _Tp >::operator=(), indirect_array< _Tp >::operator=(), iostream_withassign::operator=(), operator==(), operator>(), operator>=(), operator>>(), slice_array< _Tp >::operator>>=(), gslice_array< _Tp >::operator>>=(), mask_array< _Tp >::operator>>=(), indirect_array< _Tp >::operator>>=(), valarray< _Tp >::operator>>=(), map< _Key, _Tp,, >::operator[](), _Bit_iter< _Ref, _Ptr >::operator[](), _CArray< _Tp, _Nb >::operator[](), valarray< _Tp >::operator[](), operator^(), slice_array< _Tp >::operator^=(), gslice_array< _Tp >::operator^=(), mask_array< _Tp >::operator^=(), indirect_array< _Tp >::operator^=(), valarray< _Tp >::operator^=(), operator|(), slice_array< _Tp >::operator|=(), gslice_array< _Tp >::operator|=(), mask_array< _Tp >::operator|=(), indirect_array< _Tp >::operator|=(), operator||(), valarray< _Tp >::operator~(), pow(), random_shuffle(), rope< _CharT, _Alloc >::replace(), list< _Tp, >::resize(), sin(), sinh(), list< _Tp, >::splice(), slist< _Tp, >::splice(), sqrt(), tan(), and tanh().

◆ 

const union { ... } __inff

◆ 

const union { ... } __nanf