lauber00/elm-int64/1.2.2

NOTE: the latest version is 1.2.4

Renamed to volgariver6/elm-int64. That is where the repository lives now. It has not been published as a package under the new name.

Versions published as lauber00/elm-int64 still install under that name. 7 versions of 7 come from the new location (see their notes).

Rerouted (renamed, verified). The GitHub user or repository was renamed. The tag is still there, at the new name. The Lamdera package server serves a copy recovered from https://github.com/volgariver6/elm-int64.

What we checked: The repo moved to github.com/volgariver6/elm-int64. Rebuilt with git archive from commit 1dbe1f0355bc of https://github.com/volgariver6/elm-int64 (zip prefix lauber00-elm-int64-1d11ec4/, America/Los_Angeles times): the zip is byte-identical to the one package.elm-lang.org recorded, SHA-1 d5d5a2321b9341580b0e5bed13e4924afd663dfe.

The Lamdera compiler uses this copy and prints a one-line notice saying so. elm itself fails to download this version.

Details · package.elm-lang.org's zip: https://github.com/lauber00/elm-int64/zipball/1.2.2/

Int64

An efficient 64-bit integer with correct overflow.

Bitwise operators in javascript can only use 32 bits. Sometimes, external protocols use 64-bit integers. This package implementes such integers with "correct" overflow behavior.

This is a low-level package focussed on speed. The 64-bit integers are represented as a 2-tuple of 32-bit numbers.

type alias Int64 =
( Int, Int )

A 64-bit integer type with correct overflow behavior

Internally, the number is stored as two 32-bit integers.

fromInt : Int -> Int64

Convert a Int to Int64. This is guaranteed to work for integers in the safe JS range.

fromInt 42
    |> toSignedString
    --> "42"
fromInt32s : Int -> Int -> Int64

Give two integers, corresponding to the upper and lower 32 bits

fromInt32s 4 2
    |> toHex
    --> "0000000400000002"

Arithmetic

add : Int64 -> Int64 -> Int64

64-bit addition, with correct overflow

fromInt32s 0xFFFFFFFF 0xFFFFFFFF
    |> Int64.add (Int64.fromInt 1)
    |> Int64.toUnsignedString
    --> "0"


fromInt32s 0xFFFFFFFF 0xFFFFFFFF
    |> Int64.add (Int64.fromInt 2)
    |> Int64.toUnsignedString
    --> "1"
subtract : Int64 -> Int64 -> Int64

64-bit subtraction, with correct overflow

-- equivalent to `0 - 1`
Int64.subtract  (Int64.fromInt 0) (Int64.fromInt 1)
    |> Int64.toUnsignedString
    --> "18446744073709551615"


-- equivalent to `0 - 1`
Int64.subtract  (Int64.fromInt 0) (Int64.fromInt 1)
    |> Int64.toSignedString
    --> "-1"




-- equivalent to `1 - 0`
Int64.subtract  (Int64.fromInt 1) (Int64.fromInt 0)
    |> Int64.toUnsignedString
    --> "1"

Bitwise

and : Int64 -> Int64 -> Int64

Bitwise and

or : Int64 -> Int64 -> Int64

Bitwise or

xor : Int64 -> Int64 -> Int64

Bitwise xor

complement : Int64 -> Int64

Bitwise complement

shiftLeftBy : Int -> Int64 -> Int64

Left bitwise shift, typically written <<

Fills in zeros from the right.

Int64.fromInt32s 0xDEADBEAF 0xBAAAAAAD
    |> Int64.shiftLeftBy 16
    |> Int64.toHex
    --> "beafbaaaaaad0000"
shiftRightZfBy : Int -> Int64 -> Int64

Right bitwise shift, typically written >> (but >>> in JavaScript)

Fills in zeros from the left.

Int64.fromInt32s 0xDEADBEAF 0xBAAAAAAD
    |> Int64.shiftRightZfBy 16
    |> Int64.toHex
    --> "0000deadbeafbaaa"
rotateLeftBy : Int -> Int64 -> Int64

Left bitwise rotation

Int64.fromInt32s 0xDEADBEAF 0xBAAAAAAD
    |> Int64.rotateLeftBy 16
    |> Int64.toHex
    --> "beafbaaaaaaddead"
rotateRightBy : Int -> Int64 -> Int64

Right bitwise rotation

Int64.fromInt32s 0xDEADBEAF 0xBAAAAAAD
    |> Int64.rotateRightBy 16
    |> Int64.toHex
    --> "aaaddeadbeafbaaa"

Compare

signedCompare : Int64 -> Int64 -> Order

Compare two Int64 values, intepreting the bits as a signed integer.

unsignedCompare : Int64 -> Int64 -> Order

Compare two Int64 values, intepreting the bits as an unsigned integer.

Conversion to String

toSignedString : Int64 -> String

Interpret a Int64 as an unsigned integer, and give its string representation

toSignedString (fromInt 10)
    --> "10"


toSignedString (fromInt -10)
    --> "-10"
toUnsignedString : Int64 -> String

Interpret a Int64 as an unsigned integer, and give its string representation

toUnsignedString (fromInt 10)
    --> "10"


toUnsignedString (fromInt -10)
    --> "18446744073709551606"
toHex : Int64 -> String

Convert a Int64 to a hexadecimal string

toHex (fromInt (256 - 1))
    -->  "00000000000000ff"
toBitString : Int64 -> String

Bits as a string of 0s and 1s in big-endian order.

toBitString (fromInt 42)
    --> "0000000000000000000000000000000000000000000000000000000000101010"

Conversion to Bytes

decoder : Endianness -> Decoder Int64

A elm/bytes Decoder for Int64

encoder : Endianness -> Int64 -> Encoder

A elm/bytes Encoder for Int64

toByteValues : Int64 -> List Int

Convert an Int64 to its 8 byte values in big-endian order

toByteValues  (fromInt 0xDEADBEAF)
    --> [0,0,0,0,222,173,190,175]
toBits : Int64 -> List Bool

The individual bits as a list of Bool in big-endian order.

toBits (fromInt 10)
    --> [False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,True,False,True,False]

ZigZag

fromZigZag : Int64 -> Int64

Convert an Int64 with zigZag algorithm to its original Int64 value

fromZigZag (0, 20)
    --> (0, 10)
toZigZag : Int64 -> Int64

Convert an Int64 to a new Int64 with zigZag algorithm

toZigZag (0, 10)
    --> (0, 20)

Conversion to Int

toInt : Int64 -> Int

Give an Int64 var, corresponding to Int var

toInt (0, 2)
    --> 2