mirror of
https://sourceware.org/git/glibc.git
synced 2024-12-31 23:11:09 +00:00
68d7128942
The k>>31 in signgam = 1 - (((k&(k>>31))&1)<<1); is not portable: * The ISO C standard says "If E1 has a signed type and a negative value, the resulting value is implementation-defined." (this is still in C23). * If the int type is larger than 32 bits (e.g. a 64-bit type), then k = INT_MAX; line 144 will make k>>31 put 1 in bit 0 (thus signgam will be -1) while 0 is expected. Moreover, instead of the fx >= 0x1p31f condition, testing fx >= 0 is probably better for 2 reasons: The signgam expression has more or less a condition on the sign of fx (the goal of k>>31, which can be dropped with this new condition). Since fx ≥ 0 should be the most common case, one can get signgam directly in this case (value 1). And this simplifies the expression for the other case (fx < 0). This new condition may be easier/faster to test on the processor (e.g. by avoiding a load of a constant from the memory). This is commit d41459c731865516318f813cf4c966dafa0eecbf from CORE-MATH. Checked on x86_64-linux-gnu. |
||
---|---|---|
.. | ||
dbl-64 | ||
float128 | ||
flt-32 | ||
ldbl-64-128 | ||
ldbl-96 | ||
ldbl-128 | ||
ldbl-128ibm | ||
ldbl-128ibm-compat | ||
ldbl-opt | ||
soft-fp | ||
ieee754.h | ||
k_standard.c | ||
k_standardf.c | ||
k_standardl.c | ||
libm-alias-finite.h | ||
Makefile | ||
s_lib_version.c | ||
s_matherr.c | ||
s_signgam.c |