elm-lang/core/4.0.3

NOTE: this package moved to elm/core

NOTE: this package is not compatible with Elm 0.19.1

Bitwise

Library for bitwise operations.

Basic Operations

and : Int -> Int -> Int

Bitwise AND

or : Int -> Int -> Int

Bitwise OR

xor : Int -> Int -> Int

Bitwise XOR

complement : Int -> Int

Flip each bit individually, often called bitwise NOT

Bit Shifts

shiftLeft : Int -> Int -> Int

Shift bits to the left by a given offset, filling new bits with zeros. This can be used to multiply numbers by powers of two.

8 `shiftLeft` 1 == 16
8 `shiftLeft` 2 == 32
shiftRight : Int -> Int -> Int

Shift bits to the right by a given offset, filling new bits with whatever is the topmost bit. This can be used to divide numbers by powers of two.

 32 `shiftRight` 1 == 16
 32 `shiftRight` 2 == 8
-32 `shiftRight` 1 == -16

This is called an arithmetic right shift, often written (>>), and sometimes called a sign-propagating right shift because it fills empty spots with copies of the highest bit.

shiftRightLogical : Int -> Int -> Int

Shift bits to the right by a given offset, filling new bits with zeros.

 32 `shiftRightLogical` 1 == 16
 32 `shiftRightLogical` 2 == 8
-32 `shiftRightLogical` 1 == 2147483632

This is called an logical right shift, often written (>>>), and sometimes called a zero-fill right shift because it fills empty spots with zeros.