SDL  2.0
s_floor.c File Reference
#include "math_libm.h"
#include "math_private.h"
+ Include dependency graph for s_floor.c:

Go to the source code of this file.

Functions

 libm_hidden_proto (floor)
 

Variables

static double huge_val = 1.0e300
 

Function Documentation

libm_hidden_proto ( floor  )

Definition at line 36 of file s_floor.c.

References EXTRACT_WORDS, huge_val, i, i1, INSERT_WORDS, and j.

43 {
44  int32_t i0, i1, j0;
45  u_int32_t i, j;
46  EXTRACT_WORDS(i0, i1, x);
47  j0 = ((i0 >> 20) & 0x7ff) - 0x3ff;
48  if (j0 < 20) {
49  if (j0 < 0) { /* raise inexact if x != 0 */
50  if (huge_val + x > 0.0) { /* return 0*sign(x) if |x|<1 */
51  if (i0 >= 0) {
52  i0 = i1 = 0;
53  } else if (((i0 & 0x7fffffff) | i1) != 0) {
54  i0 = 0xbff00000;
55  i1 = 0;
56  }
57  }
58  } else {
59  i = (0x000fffff) >> j0;
60  if (((i0 & i) | i1) == 0)
61  return x; /* x is integral */
62  if (huge_val + x > 0.0) { /* raise inexact flag */
63  if (i0 < 0)
64  i0 += (0x00100000) >> j0;
65  i0 &= (~i);
66  i1 = 0;
67  }
68  }
69  } else if (j0 > 51) {
70  if (j0 == 0x400)
71  return x + x; /* inf or NaN */
72  else
73  return x; /* x is integral */
74  } else {
75  i = ((u_int32_t) (0xffffffff)) >> (j0 - 20);
76  if ((i1 & i) == 0)
77  return x; /* x is integral */
78  if (huge_val + x > 0.0) { /* raise inexact flag */
79  if (i0 < 0) {
80  if (j0 == 20)
81  i0 += 1;
82  else {
83  j = i1 + (1 << (52 - j0));
84  if (j < (u_int32_t) i1)
85  i0 += 1; /* got a carry */
86  i1 = j;
87  }
88  }
89  i1 &= (~i);
90  }
91  }
92  INSERT_WORDS(x, i0, i1);
93  return x;
94 }
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1574
signed int int32_t
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int in i)
Definition: SDL_x11sym.h:50
unsigned int u_int32_t
Definition: math_private.h:29
static double huge_val
Definition: s_floor.c:33
#define EXTRACT_WORDS(ix0, ix1, d)
Definition: math_private.h:93
#define INSERT_WORDS(d, ix0, ix1)
Definition: math_private.h:121
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int int in j)
Definition: SDL_x11sym.h:50
const GLubyte GLuint GLuint GLuint GLuint alpha GLboolean GLboolean GLboolean GLboolean alpha GLint GLint GLsizei GLsizei GLenum type GLenum GLint GLenum GLint GLint GLsizei GLsizei GLint border GLenum GLint GLint GLint GLint GLint GLsizei GLsizei height GLsizei GLsizei GLenum GLenum const GLvoid *pixels GLenum GLint i1
Definition: SDL_glfuncs.h:140

Variable Documentation

double huge_val = 1.0e300
static

Definition at line 33 of file s_floor.c.

Referenced by libm_hidden_proto().