Provide highestOneBit function in Data.Bits module
This function yields the largest power of 2 less than or equal to the given number.
Relative to the Java standard library, which provides this function, there is a gap in the Haskell library, even though the Haskell docs describe a method to calculate logBase2 via the `countLeadingZeros` function.
From the Java documentation:
The implementations of the "bit twiddling" methods (such as
highestOneBit
andnumberOfTrailingZeros
) are based on material from Henry S. Warren, Jr.'s ''Hacker's Delight'', (Addison Wesley, 2002).
Trac metadata
Trac field | Value |
---|---|
Version | 8.2.2 |
Type | FeatureRequest |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | libraries/base |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | |
Operating system | |
Architecture |