corrects ambiguity in frsqrt
This commit is contained in:
parent
6fcb3dbb66
commit
f0b582df6c
@ -556,7 +556,7 @@ uint64_t constexpr frsqrt7_general(const unsigned s, const unsigned e, const uin
|
||||
int64_t normalized_exp = exp;
|
||||
uint64_t normalized_sig = sig;
|
||||
if(subnormal) {
|
||||
unsigned nr_leadingzeros = __builtin_clzll(sig) - (64 - s);
|
||||
signed nr_leadingzeros = __builtin_clzll(sig) - (64 - s);
|
||||
normalized_exp = -nr_leadingzeros;
|
||||
normalized_sig = (sig << (1 + nr_leadingzeros)) & ((1ULL << s) - 1);
|
||||
}
|
||||
@ -566,8 +566,8 @@ uint64_t constexpr frsqrt7_general(const unsigned s, const unsigned e, const uin
|
||||
// result significand is zero.
|
||||
uint64_t out_sig = rsqrt_table[exp_idx][sig_idx] << (s - 7);
|
||||
// The output exponent equals floor((3*B - 1 - the normalized input exponent) / 2), where B is the exponent bias.
|
||||
unsigned bias = 1UL << (e - 1);
|
||||
uint64_t out_exp = (3 * (bias - 1) - 1 - normalized_exp) / 2;
|
||||
unsigned bias = (1UL << (e - 1)) - 1;
|
||||
uint64_t out_exp = (3 * bias - 1 - normalized_exp) / 2;
|
||||
// The output sign equals the input sign.
|
||||
return (sign << (s + e)) | (out_exp << s) | out_sig;
|
||||
}
|
||||
@ -668,8 +668,8 @@ bool frec_general(uint64_t& res, const unsigned s, const unsigned e, const uint6
|
||||
int64_t normalized_exp = subnormal ? -nr_leadingzeros : exp;
|
||||
uint64_t normalized_sig = subnormal ? ((sig << (1 + nr_leadingzeros)) & ((1ULL << s) - 1)) : sig;
|
||||
unsigned idx = (normalized_sig >> (s - 7)) & 0x7f;
|
||||
unsigned bias = 1UL << (e - 1);
|
||||
uint64_t mid_exp = 2 * (bias - 1) - 1 - normalized_exp;
|
||||
unsigned bias = (1UL << (e - 1)) - 1;
|
||||
uint64_t mid_exp = 2 * (bias)-1 - normalized_exp;
|
||||
uint64_t mid_sig = rec_table[idx] << (s - 7);
|
||||
|
||||
uint64_t out_exp = mid_exp;
|
||||
|
Loading…
x
Reference in New Issue
Block a user