ReactOS 0.4.15-dev-7931-gfd331f1
modf.c File Reference
#include "libm.h"
#include "libm_util.h"
Include dependency graph for modf.c:

Go to the source code of this file.

Functions

double modf (double x, double *iptr)
 

Function Documentation

◆ modf()

double 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}
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLenum GLint GLuint mask
Definition: glext.h:6028
#define EXPSHIFTBITS_DP64
Definition: libm_util.h:56
#define GET_BITS_DP64(x, ux)
Definition: libm_util.h:118
#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
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