Puregrain.Internal.Exact
- Package
- purescript-puregrain
- Repository
- roman-mkh/puregrain
Fifth and cube roots from exact operations only (+, −, ×, ÷ and
comparisons), so that every JavaScript engine gives the same results:
ECMA-262 lets Math.pow and Math.cbrt differ between engines, but
not these operations. Internal: may change without notice.
Each root scales its input by exact powers of 2 into a small range,
[1/32, 1) for the fifth root and [1/8, 1) for the cube root, takes a
fixed number of Newton's steps from 1, and scales back. Scaling by
powers of 2 loses nothing, so the same number of steps fits every
input, from the smallest denormal up, and fifthRoot (32.0 * x) is
exactly 2.0 * fifthRoot x.
The results are within two units in the last place of the nearest number to the true root, mostly that number itself, so two neighbouring inputs can get roots up to two units apart in either order. Why, how often, and why it doesn't matter for dithering: docs/exact-arithmetic.md.
- Modules
- Puregrain
- Puregrain.
Cells - Puregrain.
Dither - Puregrain.
Gamma - Puregrain.
Internal. Exact - Puregrain.
Internal. Fifo - Puregrain.
Internal. Gamma - Puregrain.
Internal. Image - Puregrain.
Internal. Kernel - Puregrain.
Internal. Quantize - Puregrain.
Internal. Row - Puregrain.
Internal. SelfCheck - Puregrain.
Internal. State - Puregrain.
Internal. Step - Puregrain.
Internal. Util - Puregrain.
Kernel - Puregrain.
Machine. C64 - Puregrain.
Machine. ZxSpectrum - Puregrain.
Ordered - Puregrain.
Palette - Puregrain.
Palette. Presets - Puregrain.
Pixel - Puregrain.
Quantize - Puregrain.
SelfCheck