projects
/
musl
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
elf.h: add ELFCOMPRESS_ZSTD
[musl]
/
src
/
math
/
nexttoward.c
diff --git
a/src/math/nexttoward.c
b/src/math/nexttoward.c
index
741b6b5
..
827ee5c
100644
(file)
--- a/
src/math/nexttoward.c
+++ b/
src/math/nexttoward.c
@@
-6,41
+6,37
@@
double nexttoward(double x, long double y)
return nextafter(x, y);
}
#else
return nextafter(x, y);
}
#else
-#define SIGN ((uint64_t)1<<63)
-
double nexttoward(double x, long double y)
{
double nexttoward(double x, long double y)
{
- union
dshape ux
;
+ union
{double f; uint64_t i;} ux = {x}
;
int e;
if (isnan(x) || isnan(y))
return x + y;
if (x == y)
return y;
int e;
if (isnan(x) || isnan(y))
return x + y;
if (x == y)
return y;
- ux.value = x;
if (x == 0) {
if (x == 0) {
- ux.
bits
= 1;
+ ux.
i
= 1;
if (signbit(y))
if (signbit(y))
- ux.
bits |= SIGN
;
+ ux.
i |= 1ULL<<63
;
} else if (x < y) {
if (signbit(x))
} else if (x < y) {
if (signbit(x))
- ux.
bits
--;
+ ux.
i
--;
else
else
- ux.
bits
++;
+ ux.
i
++;
} else {
if (signbit(x))
} else {
if (signbit(x))
- ux.
bits
++;
+ ux.
i
++;
else
else
- ux.
bits
--;
+ ux.
i
--;
}
}
- e = ux.
bits
>>52 & 0x7ff;
- /* raise overflow if ux.
value
is infinite and x is finite */
+ e = ux.
i
>>52 & 0x7ff;
+ /* raise overflow if ux.
f
is infinite and x is finite */
if (e == 0x7ff)
if (e == 0x7ff)
- return x + x;
- /* raise underflow if ux.value is subnormal or zero */
- if (e == 0) {
- volatile float z = x*x + ux.value*ux.value;
- }
- return ux.value;
+ FORCE_EVAL(x+x);
+ /* raise underflow if ux.f is subnormal or zero */
+ if (e == 0)
+ FORCE_EVAL(x*x + ux.f*ux.f);
+ return ux.f;
}
#endif
}
#endif