This is an alternative site for discovering Elm packages. You may be looking for the official Elm package site instead.
Unsigned 32 or 64 bit integers and related operations
version 2.1.1
license MIT
native-modules False
elm-version 0.18.0 <= v < 0.19.0
Tag 2.1.1
Committed At 2017-11-29 16:27:36 UTC
elm-lang/core 5.1.1 <= v < 6.0.0 5.1.1

README

elm-word

elm-package CircleCI

Unsigned 32 or 64 bit integers and related operations.

Use the Word type to hold either 32 or 64 bit unsigned integers. Use the exposed type constructors W (for "word") and D (for "double word") to store values as words.

import Word exposing (Word(D, W))

Operations

The following operations are provided.

  • add - modulo addition
  • and - bitwise and
  • xor - bitwise xor
  • complement - bitwise inversion
  • rotateRightBy - rotate right
  • shiftRightZfBy - logical shift right

Note that the set of operations is the minimal required to implement SHA-2.

Examples

Addition of words is modulo 32 bits.

add (W 0x80000000)
    (W 0x80000003)
--> W 3

Addition of double words is modulo 64 bits.

add (D 0 0xFFFFFFFF)
    (D 0 1)
--> D 1 0

Large Values in Elm

Double words are stored as two 32 bit values because Elm makes arithmetic mistakes with larger values. For example, try typing this into the elm repl:

$ elm repl

---- elm-repl 0.18.0 -----------------------------------------------------------

> 2 ^ 60 + 55 == 2 ^ 60
True : Bool

Related Libraries