nodef / extra-bit.elm

The bit is a basic unit of information in information theory, computing.

Home Page:https://package.elm-lang.org/packages/elmw/extra-bit/latest/

Repository from Github https://github.comnodef/extra-bit.elmRepository from Github https://github.comnodef/extra-bit.elm

The bit is a basic unit of information in information theory, computing.
πŸ“¦ Package, :blue_book: Wiki.


This package includes bit twiddling hacks by Sean Eron Anderson and many others.

Stability: Experimental.


import Bit exposing (..)

count 7
-- 3 (111 β‡’ 3)

parity 8 2
-- 2 (10,00 β‡’ 10)

swap 6 1 0 1
-- 5 (110 β‡’ 101)

reverse 0xFFFF0000
-- 65535 (0x0000FFFF)

signExtend 15 4
-- -1


Index

Method Action
get Get a bit.
set Set a bit.
toggle Toggle a bit.
swap Swap bit sequences.
count Count bits set.
parity Get n-bit parity.
scan Get index of first set bit from LSB.
merge Merge bits as per mask.
interleave Interleave bits of two int16s.
rotate Rotate bits.
reverse Reverse all bits.
signExtend Sign extend variable bit-width integer.


References



About

The bit is a basic unit of information in information theory, computing.

https://package.elm-lang.org/packages/elmw/extra-bit/latest/

License:MIT License


Languages

Language:Elm 100.0%