123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- #include <math.h>
- #include "math_private.h"
- double
- trunc (double x)
- {
- int32_t i0, _j0;
- u_int32_t i1;
- int sx;
- EXTRACT_WORDS (i0, i1, x);
- sx = i0 & 0x80000000;
- _j0 = ((i0 >> 20) & 0x7ff) - 0x3ff;
- if (_j0 < 20)
- {
- if (_j0 < 0)
-
- INSERT_WORDS (x, sx, 0);
- else
- INSERT_WORDS (x, sx | (i0 & ~(0x000fffff >> _j0)), 0);
- }
- else if (_j0 > 51)
- {
- if (_j0 == 0x400)
-
- return x + x;
- }
- else
- {
- INSERT_WORDS (x, i0, i1 & ~(0xffffffffu >> (_j0 - 20)));
- }
- return x;
- }
- libm_hidden_def(trunc)
|