Skip to content

bit function seems to be working incorrectly #1

@clample

Description

@clample

From the documentation for bit in Data.Bits, it seems thatbit should set the ith bit set and all other bits clear.

It seems that when i >= 8 this library is setting the first byte correctly but then all later bits are set instead of clear.

Prelude BS> import qualified Data.ByteString.Base16 as B16
Prelude BS B16> import Data.Bits
Prelude BS B16 Data.Bits> import Data.Bits.ByteString
Prelude BS B16 Data.Bits Data.Bits.ByteString> B16.encode . bit 8
Prelude BS B16 Data.Bits Data.Bits.ByteString> B16.encode . bit $ 8
"01ff"

I think that the last line should return 0100 rather than 01ff

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions