-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Labels
Description
ILogB is implemented on Half as such:
| return MinExponent - (BitOperations.LeadingZeroCount(x.TrailingSignificand) - BiasedExponentLength); |
and TrailingSignificand is a ushort
| internal ushort TrailingSignificand |
However, BitOperations.LeadingZeroCount has no overload that accepts a ushort. So it is implicitly widened to the uint overload, and calculates the leading zero count as if the number had a 32-bit width instead of 16-bit.
I believe that means that Half.ILogB may be off by 16 for subnormal values (and probably BFloat16).
For example, for Half.Epsilon I would expect the ilogb to be -24, but is reported as -40.
Reactions are currently unavailable