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-safe-int/zipball/1.0.0/
Unchecked versions of SafeInt functions which operate directly on Float values.
import SafeInt.Unchecked as Unchecked
-- `2^40 / 10`
Unchecked.pow 2 40
|> Unchecked.divBy 10
--> 109951162777It is recommended to use SafeInt functions instead of Unchecked functions,
unless more speed is required at the cost of some lost safety and features.
Unchecked functions are faster than corresponding SafeInt functions because they
Float valuesundefined valueminValue and maxValueTherefore with Unchecked functions it's users responsibility to make sure
that arguments are valid and such that result will be within allowed limits.
As long as undefined behavior is avoided,
Unchecked functions will work exactly like corresponding SafeInt functions.
When using Unchecked functions
minValue and maxValue andSafeInt function would not return undefined*) This doesn't apply to round, ceiling, truncate and floor
which allow non-integer arguments.
If these rules are not followed, behavior of Unchecked functions is undefined.
Maximum possible value, 2^53 - 1 = 9 007 199 254 740 991.
Equal to Number.MAX_SAFE_INTEGER in JavaScript.
SafeInt.Unchecked.maxValue
--> 9007199254740991Convert Int to Float.
Behavior is undefined if
Note: You can use Basics.toFloat instead of this function.
Note: Unlike SafeInt.fromInt,
this function does not allow non-integer argument.
Convert Float to Int.
Behavior is undefined if
Note: You can use Basics.round, Basics.floor or Basics.ceiling instead of this function.
Note: Unlike SafeInt.toInt,
return value is Int instead of Maybe Int as Unchecked functions don't support undefined value.
Comparison of rounding functions:
-3.8 -3.5 -3.2 ~ 3.2 3.5 3.8
---- ---- ---- ---- ---- ----
round -4 -3 -3 3 4 4
ceiling -3 -3 -3 4 4 4
truncate -3 -3 -3 3 3 3
floor -4 -4 -4 3 3 3Power aka exponentiation, rounding towards zero.
Behavior is undefined if
pow 0 b, b <= 0minValue or above maxValueminValue or above maxValueThe table below shows the return values of pow a b near zero.
U denotes undefined behavior and *0 denotes non-integer result rounded towards zero.
b: -2 -1 0 1 2
a -- -- -- -- --
--
-2 *0 *0 1 -2 4
-1 1 -1 1 -1 1
0 U U U 0 0
1 1 1 1 1 1
2 *0 *0 1 2 4SafeInt.Unchecked.pow 2 40
--> 1099511627776Note: Opinions differ on what the result of 0 ^ 0 should be.
SafeInt takes the stance that when uncertain, it's undefined behavior.
For more information see e.g. Zero to the power of zero🢅.
Integer division, rounding towards negative infinity.
See Division undefined for undefined behavior and SafeInt § Division Basics for more information about division functions.
SafeInt.Unchecked.div 1234 100
--> 12
SafeInt.Unchecked.div -1234 100
--> -13Remainder after div. This is also used for modular arithmetic🢅.
See Division undefined for undefined behavior and SafeInt § Division Basics for more information about division functions.
SafeInt.Unchecked.mod 1234 100
--> 34
SafeInt.Unchecked.mod -1234 100
--> 66Integer division, rounding towards zero.
This is similar to // operator.
See Division undefined for undefined behavior and SafeInt § Division Basics for more information about division functions.
SafeInt.Unchecked.quotient 1234 100
--> 12
SafeInt.Unchecked.quotient -1234 100
--> -12Remainder after quotient.
See Division undefined for undefined behavior and SafeInt § Division Basics for more information about division functions.
SafeInt.Unchecked.remainder 1234 100
--> 34
SafeInt.Unchecked.remainder -1234 100
--> -34Functions divBy, modBy, quotientBy and remainderBy
are same as basic division functions, except with reversed arguments.
modBy is similar to Basics.modBy and remainderBy to Basics.remainderBy.
import SafeInt.Unchecked as Unchecked
-- `2^40 / 10`
Unchecked.pow 2 40
|> Unchecked.divBy 10
--> 109951162777Same as mod except with reversed arguments.
This is similar to Basics.modBy.
Same as quotient except with reversed arguments.
Same as remainder except with reversed arguments.
This is similar to Basics.remainderBy.
Minimum possible value,
- (2^53 - 1) = - 9 007 199 254 740 991.Equal to
Number.MIN_SAFE_INTEGERin JavaScript.