ReactOS 0.4.17-dev-1321-g5c122a9
log10.c File Reference
#include <math.h>
#include <stdint.h>
Include dependency graph for log10.c:

Go to the source code of this file.

Functions

double log10 (double x)
 

Variables

static const double ivln10hi = 4.34294481878168880939e-01
 
static const double ivln10lo = 2.50829467116452752298e-11
 
static const double log10_2hi = 3.01029995663611771306e-01
 
static const double log10_2lo = 3.69423907715893078616e-13
 
static const double Lg1 = 6.666666666666735130e-01
 
static const double Lg2 = 3.999999999940941908e-01
 
static const double Lg3 = 2.857142874366239149e-01
 
static const double Lg4 = 2.222219843214978396e-01
 
static const double Lg5 = 1.818357216161805012e-01
 
static const double Lg6 = 1.531383769920937332e-01
 
static const double Lg7 = 1.479819860511658591e-01
 

Function Documentation

◆ log10()

double log10 ( double  x)

Definition at line 50 of file log10.c.

51{
52 union {double f; uint64_t i;} u = {x};
53 double_t hfsq,f,s,z,R,w,t1,t2,dk,y,hi,lo,val_hi,val_lo;
54 uint32_t hx;
55 int k;
56
57 hx = u.i>>32;
58 k = 0;
59 if (hx < 0x00100000 || hx>>31) {
60 if (u.i<<1 == 0)
61 return -1/(x*x); /* log(+-0)=-inf */
62 if (hx>>31)
63 return (x-x)/0.0; /* log(-#) = NaN */
64 /* subnormal number, scale x up */
65 k -= 54;
66 x *= 0x1p54;
67 u.f = x;
68 hx = u.i>>32;
69 } else if (hx >= 0x7ff00000) {
70 return x;
71 } else if (hx == 0x3ff00000 && u.i<<32 == 0)
72 return 0;
73
74 /* reduce x into [sqrt(2)/2, sqrt(2)] */
75 hx += 0x3ff00000 - 0x3fe6a09e;
76 k += (int)(hx>>20) - 0x3ff;
77 hx = (hx&0x000fffff) + 0x3fe6a09e;
78 u.i = (uint64_t)hx<<32 | (u.i&0xffffffff);
79 x = u.f;
80
81 f = x - 1.0;
82 hfsq = 0.5*f*f;
83 s = f/(2.0+f);
84 z = s*s;
85 w = z*z;
86 t1 = w*(Lg2+w*(Lg4+w*Lg6));
87 t2 = z*(Lg1+w*(Lg3+w*(Lg5+w*Lg7)));
88 R = t2 + t1;
89
90 /* See log2.c for details. */
91 /* hi+lo = f - hfsq + s*(hfsq+R) ~ log(1+f) */
92 hi = f - hfsq;
93 u.f = hi;
94 u.i &= (uint64_t)-1<<32;
95 hi = u.f;
96 lo = f - hi - hfsq + s*(hfsq+R);
97
98 /* val_hi+val_lo ~ log10(1+f) + k*log10(2) */
99 val_hi = hi*ivln10hi;
100 dk = k;
101 y = dk*log10_2hi;
102 val_lo = dk*log10_2lo + (lo+hi)*ivln10lo + lo*ivln10hi;
103
104 /*
105 * Extra precision in for adding y is not strictly needed
106 * since there is no very large cancellation near x = sqrt(2) or
107 * x = 1/sqrt(2), but we do it anyway since it costs little on CPUs
108 * with some parallelism and it reduces the error for many args.
109 */
110 w = y + val_hi;
111 val_lo += (y - w) + val_hi;
112 val_hi = w;
113
114 return val_lo + val_hi;
115}
const UCHAR * dk
Definition: bcrypt.c:517
@ R
Definition: bidi.c:79
UINT32 uint32_t
Definition: types.h:75
UINT64 uint64_t
Definition: types.h:77
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31
static const uint32_t k[]
Definition: sha256.c:24
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLdouble s
Definition: gl.h:2039
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
GLfloat f
Definition: glext.h:7540
GLubyte GLubyte GLubyte GLubyte w
Definition: glext.h:6102
GLdouble GLdouble z
Definition: glext.h:5874
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
#define f
Definition: ke_i.h:83
#define uint64_t
Definition: nsiface.idl:62
static const double ivln10lo
Definition: log10.c:39
static const double Lg7
Definition: log10.c:48
static const double Lg6
Definition: log10.c:47
static const double log10_2lo
Definition: log10.c:41
static const double ivln10hi
Definition: log10.c:38
static const double Lg4
Definition: log10.c:45
static const double Lg5
Definition: log10.c:46
static const double log10_2hi
Definition: log10.c:40
static const double Lg3
Definition: log10.c:44
static const double Lg2
Definition: log10.c:43
static const double Lg1
Definition: log10.c:42

Referenced by log10f(), and log10l().

Variable Documentation

◆ ivln10hi

const double ivln10hi = 4.34294481878168880939e-01
static

Definition at line 38 of file log10.c.

Referenced by log10().

◆ ivln10lo

const double ivln10lo = 2.50829467116452752298e-11
static

Definition at line 39 of file log10.c.

Referenced by log10().

◆ Lg1

const double Lg1 = 6.666666666666735130e-01
static

Definition at line 42 of file log10.c.

Referenced by log10().

◆ Lg2

const double Lg2 = 3.999999999940941908e-01
static

Definition at line 43 of file log10.c.

Referenced by log10().

◆ Lg3

const double Lg3 = 2.857142874366239149e-01
static

Definition at line 44 of file log10.c.

Referenced by log10().

◆ Lg4

const double Lg4 = 2.222219843214978396e-01
static

Definition at line 45 of file log10.c.

Referenced by log10().

◆ Lg5

const double Lg5 = 1.818357216161805012e-01
static

Definition at line 46 of file log10.c.

Referenced by log10().

◆ Lg6

const double Lg6 = 1.531383769920937332e-01
static

Definition at line 47 of file log10.c.

Referenced by log10().

◆ Lg7

const double Lg7 = 1.479819860511658591e-01
static

Definition at line 48 of file log10.c.

Referenced by log10().

◆ log10_2hi

const double log10_2hi = 3.01029995663611771306e-01
static

Definition at line 40 of file log10.c.

Referenced by log10().

◆ log10_2lo

const double log10_2lo = 3.69423907715893078616e-13
static

Definition at line 41 of file log10.c.

Referenced by log10().