[encode_real8] improve handling of tiny floats
This commit is contained in:
parent
e72b792f6f
commit
56a99c8e58
1 changed files with 1 additions and 2 deletions
|
|
@ -149,7 +149,7 @@ def encode_real8(fnums: NDArray[numpy.float64]) -> NDArray[numpy.uint64]:
|
|||
gds_exp = exp16 + 64
|
||||
|
||||
neg_biased = (gds_exp < 0)
|
||||
gds_mant[neg_biased] >>= (gds_exp[neg_biased] * 4).astype(numpy.uint16)
|
||||
gds_mant[neg_biased] >>= (-gds_exp[neg_biased] * 4).astype(numpy.uint16)
|
||||
gds_exp[neg_biased] = 0
|
||||
|
||||
too_big = (gds_exp > 0x7f) & ~(zero | subnorm)
|
||||
|
|
@ -160,7 +160,6 @@ def encode_real8(fnums: NDArray[numpy.float64]) -> NDArray[numpy.uint64]:
|
|||
|
||||
real8 = sign | gds_exp_bits | gds_mant
|
||||
real8[zero] = 0
|
||||
real8[gds_exp < -14] = 0 # number is too small
|
||||
|
||||
return real8.astype(numpy.uint64, copy=False)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue