ReactOS 0.4.16-dev-197-g92996da
floor.c File Reference
#include "libm.h"
#include "libm_util.h"
#include "libm_errno.h"
#include "libm_inlines.h"
Include dependency graph for floor.c:

Go to the source code of this file.

Macros

#define USE_HANDLE_ERROR
 

Functions

double FN_PROTOTYPE() floor (double x)
 

Macro Definition Documentation

◆ USE_HANDLE_ERROR

#define USE_HANDLE_ERROR

Definition at line 31 of file floor.c.

Function Documentation

◆ floor()

double FN_PROTOTYPE() floor ( double  x)

Definition at line 37 of file floor.c.

38{
39 double r;
40 long long rexp, xneg;
41
42
43 unsigned long long ux, ax, ur, mask;
44
45 GET_BITS_DP64(x, ux);
46 ax = ux & (~SIGNBIT_DP64);
47 xneg = (ux != ax);
48
49 if (ax >= 0x4340000000000000)
50 {
51 /* abs(x) is either NaN, infinity, or >= 2^53 */
52 if (ax > 0x7ff0000000000000)
53 /* x is NaN */
54 return _handle_error("floor", OP_FLOOR, ux|0x0008000000000000, _DOMAIN,
55 0, EDOM, x, 0.0, 1);
56 else
57 return x;
58 }
59 else if (ax < 0x3ff0000000000000) /* abs(x) < 1.0 */
60 {
61 if (ax == 0x0000000000000000)
62 /* x is +zero or -zero; return the same zero */
63 return x;
64 else if (xneg) /* x < 0.0 */
65 return -1.0;
66 else
67 return 0.0;
68 }
69 else
70 {
71 r = x;
72 rexp = ((ux & EXPBITS_DP64) >> EXPSHIFTBITS_DP64) - EXPBIAS_DP64;
73 /* Mask out the bits of r that we don't want */
74 mask = 1;
75 mask = (mask << (EXPSHIFTBITS_DP64 - rexp)) - 1;
76 ur = (ux & ~mask);
77 PUT_BITS_DP64(ur, r);
78 if (xneg && (ur != ux))
79 /* We threw some bits away and x was negative */
80 return r - 1.0;
81 else
82 return r;
83 }
84
85}
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
#define EDOM
Definition: errno.h:39
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLenum GLint GLuint mask
Definition: glext.h:6028
#define _DOMAIN
Definition: math.h:39
#define EXPSHIFTBITS_DP64
Definition: libm_util.h:56
#define GET_BITS_DP64(x, ux)
Definition: libm_util.h:118
#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
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