Rerouted (cache, verified). The original is gone. This copy comes from a Lamdera package cache made before it went. The Lamdera package server serves a copy recovered from a Lamdera package cache from 2021-02-13.
What we checked: Rebuilt from the unpacked sources in a Lamdera package cache (5 copies agree), which Elm only writes after the published SHA-1 checked out; elm.json is byte-identical to package.elm-lang.org's; the exposed modules match docs.json; the zip is our own, so its SHA-1 is not the published one.
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/malaire/elm-uint64/zipball/2.0.0/
64-bit unsigned integer using wrapping overflow.
import UInt64
-- `0 - 0xFF` wraps around to `0xFFFFFFFFFFFFFF01`
UInt64.sub UInt64.zero (UInt64.fromInt 0xFF)
|> UInt64.toHexString
--> "FFFFFFFFFFFFFF01"
-- ( 0xFFFFFFFFFFFFFFFF / 1e10, 0xFFFFFFFFFFFFFFFF % 1e10 )
UInt64.divMod UInt64.maxValue (UInt64.floor 1e10)
|> Tuple.mapBoth UInt64.toFloat UInt64.toFloat
--> ( 1844674407, 3709551615 )
UInt64.fromInt32s 0x11223344 0xAABBCCDD
|> UInt64.rotateRightBy 20
|> UInt64.toHexString
--> "BCCDD11223344AAB"Includes many conversion functions, for example converting UInt64 to String.
import UInt64
import UInt64.Digits as Digits
UInt64.fromInt 0x10F
|> UInt64.toDigits Digits.binary
|> Digits.padToPowerOfTwo '0'
|> Digits.groupToString 4 ' '
--> "0000 0001 0000 1111"Includes relatively low-level functions.
High-level functions using these low-level functions
would then belong to other packages which depend on UInt64.
For example isPrime wouldn't belong to this package,
but if someone needs add-with-carry or multiply-accumulate🢅 , those can be considered.
If you need a function which you think should be included, please create an issue🢅 mentioning use case for the function.
As fast as feasible, given the chosen implementation of three 24-bit unsigned integers. This goal is balanced with code complexity.
Handling of invalid arguments is balanced with goal of speed. See Argument handling.
Every function, no matter how trivial, has at least one full-range fuzz test.
More tests are added as seemed necessary.
Here are some quick benchmark results.
As usual I'm not interested in proper benchmarking, so take these with 2^64 grains of salt:
runs / second
pow : 64-bit number ^ 64-bit number: ~ 200 000
pow : 64-bit number ^ 251 : ~ 1 500 000
divMod: 64-bit number / 40-bit number: ~ 3 000 000
pow : 64-bit number ^ 16 : > 8 000 000
divMod: 64-bit number / 29-bit number: > 10 000 000
add, sub, mul : > 20 000 000
bitwise shift/rotate by 1 bit : > 25 000 000Benchmarking was done 2020-06-26 with version 1.1.0, elm make --optimize,
Elm 0.19.1, Firefox 68, Debian Linux and Core i5 3570K 3.4 GHz.
Some example benchmarks are included in benchmarks directory of source.