ReactOS 0.4.16-dev-122-g325d74c
modff.c File Reference
#include "libm.h"
#include "libm_util.h"
Include dependency graph for modff.c:

Go to the source code of this file.

Functions

float modff (float x, float *iptr)
 

Function Documentation

◆ modff()

float 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}
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLenum GLint GLuint mask
Definition: glext.h:6028
#define GET_BITS_SP32(x, ux)
Definition: libm_util.h:105
#define SIGNBIT_SP32
Definition: libm_util.h:68
#define EXPBIAS_SP32
Definition: libm_util.h:79
#define PUT_BITS_SP32(ux, x)
Definition: libm_util.h:111
#define EXPSHIFTBITS_SP32
Definition: libm_util.h:80