Skip to content

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
    • Help
    • Support
    • Submit feedback
  • Sign in / Register
GHC
GHC
  • Project
    • Project
    • Details
    • Activity
    • Releases
    • Cycle Analytics
    • Insights
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Charts
    • Locked Files
  • Issues 3,630
    • Issues 3,630
    • List
    • Boards
    • Labels
    • Milestones
  • Merge Requests 202
    • Merge Requests 202
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
    • Charts
  • Security & Compliance
    • Security & Compliance
    • Dependency List
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Collapse sidebar
  • Activity
  • Graph
  • Charts
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
  • Glasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #14818

Closed
Open
Opened Feb 18, 2018 by kostmo@trac-kostmo
  • Report abuse
  • New issue
Report abuse New issue

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 and numberOfTrailingZeros) 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

Related issues

  • Discussion
  • Designs
Assignee
Assign to
7.10.1
Milestone
7.10.1
Assign milestone
Time tracking
None
Due date
None
4
Labels
core libraries feature request P::normal Trac import
Assign labels
  • View project labels
Reference: ghc/ghc#14818