Closed milankl closed 2 years ago
Instead of escaping when keepbits == significand_bits(T)
I've added one line to get_shift
function get_shift(::Type{T},keepbits::Integer) where {T<:Base.IEEEFloat}
shift = Base.significand_bits(T) - keepbits # normal case
shift -= keepbits == Base.significand_bits(T) # to avoid round away from 0
return shift
end
sure whether the ==
check is here or before calling round!
probably doesn't matter but it avoids high-level branching
_Originally posted by @milankl in https://github.com/observingClouds/bitinformation_pipeline/issues/29#issuecomment-1091691892_
In Ryan's
numcodecs.bitround
https://github.com/zarr-developers/numcodecs/pull/299 it seems that a simple escape is used for keepbits=23 (because no rounding should take place).I can easily add that for BitInformation.jl too. Because at the moment we have
Meaning for the edge case of keepbits=23 there's still some rounding away from zero possible, which obviously shouldn't happen. I'll see in a patch release how to best deal with that