Skip to content

Wrong ILogB result for subnormal values #116912

Closed
@huoyaoyuan

Description

@huoyaoyuan

Math.ILogB incorrectly uses TZCNT instead of LZCNT for subnormal values:

return double.MinExponent - (BitOperations.TrailingZeroCount(x.TrailingSignificand) - double.BiasedExponentLength);

Math.ILogB(1e-308) returns -1024 on .NET 8, and -1012 on .NET 9. The correct result is -1024.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions