@ac-kit/math-numbers 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +28 -0
- package/README.md +111 -0
- package/dist/decimal/_aligned-coefficients.d.ts +5 -0
- package/dist/decimal/_aligned-coefficients.d.ts.map +1 -0
- package/dist/decimal/_aligned-coefficients.js +15 -0
- package/dist/decimal/_aligned-coefficients.js.map +1 -0
- package/dist/decimal/_normalize.d.ts +7 -0
- package/dist/decimal/_normalize.d.ts.map +1 -0
- package/dist/decimal/_normalize.js +24 -0
- package/dist/decimal/_normalize.js.map +1 -0
- package/dist/decimal/_round.d.ts +10 -0
- package/dist/decimal/_round.d.ts.map +1 -0
- package/dist/decimal/_round.js +62 -0
- package/dist/decimal/_round.js.map +1 -0
- package/dist/decimal/decimal-abs.d.ts +4 -0
- package/dist/decimal/decimal-abs.d.ts.map +1 -0
- package/dist/decimal/decimal-abs.js +6 -0
- package/dist/decimal/decimal-abs.js.map +1 -0
- package/dist/decimal/decimal-add.d.ts +4 -0
- package/dist/decimal/decimal-add.d.ts.map +1 -0
- package/dist/decimal/decimal-add.js +9 -0
- package/dist/decimal/decimal-add.js.map +1 -0
- package/dist/decimal/decimal-compare.d.ts +5 -0
- package/dist/decimal/decimal-compare.d.ts.map +1 -0
- package/dist/decimal/decimal-compare.js +10 -0
- package/dist/decimal/decimal-compare.js.map +1 -0
- package/dist/decimal/decimal-digit-at.d.ts +15 -0
- package/dist/decimal/decimal-digit-at.d.ts.map +1 -0
- package/dist/decimal/decimal-digit-at.js +26 -0
- package/dist/decimal/decimal-digit-at.js.map +1 -0
- package/dist/decimal/decimal-div.d.ts +13 -0
- package/dist/decimal/decimal-div.d.ts.map +1 -0
- package/dist/decimal/decimal-div.js +41 -0
- package/dist/decimal/decimal-div.js.map +1 -0
- package/dist/decimal/decimal-fractional-precision.d.ts +12 -0
- package/dist/decimal/decimal-fractional-precision.d.ts.map +1 -0
- package/dist/decimal/decimal-fractional-precision.js +13 -0
- package/dist/decimal/decimal-fractional-precision.js.map +1 -0
- package/dist/decimal/decimal-from-big-int.d.ts +8 -0
- package/dist/decimal/decimal-from-big-int.d.ts.map +1 -0
- package/dist/decimal/decimal-from-big-int.js +10 -0
- package/dist/decimal/decimal-from-big-int.js.map +1 -0
- package/dist/decimal/decimal-from-number.d.ts +8 -0
- package/dist/decimal/decimal-from-number.d.ts.map +1 -0
- package/dist/decimal/decimal-from-number.js +17 -0
- package/dist/decimal/decimal-from-number.js.map +1 -0
- package/dist/decimal/decimal-from-string.d.ts +8 -0
- package/dist/decimal/decimal-from-string.d.ts.map +1 -0
- package/dist/decimal/decimal-from-string.js +33 -0
- package/dist/decimal/decimal-from-string.js.map +1 -0
- package/dist/decimal/decimal-integral-fractional.d.ts +12 -0
- package/dist/decimal/decimal-integral-fractional.d.ts.map +1 -0
- package/dist/decimal/decimal-integral-fractional.js +31 -0
- package/dist/decimal/decimal-integral-fractional.js.map +1 -0
- package/dist/decimal/decimal-integral-precision.d.ts +10 -0
- package/dist/decimal/decimal-integral-precision.d.ts.map +1 -0
- package/dist/decimal/decimal-integral-precision.js +12 -0
- package/dist/decimal/decimal-integral-precision.js.map +1 -0
- package/dist/decimal/decimal-inv.d.ts +4 -0
- package/dist/decimal/decimal-inv.d.ts.map +1 -0
- package/dist/decimal/decimal-inv.js +7 -0
- package/dist/decimal/decimal-inv.js.map +1 -0
- package/dist/decimal/decimal-is-equal.d.ts +4 -0
- package/dist/decimal/decimal-is-equal.d.ts.map +1 -0
- package/dist/decimal/decimal-is-equal.js +6 -0
- package/dist/decimal/decimal-is-equal.js.map +1 -0
- package/dist/decimal/decimal-mul.d.ts +4 -0
- package/dist/decimal/decimal-mul.d.ts.map +1 -0
- package/dist/decimal/decimal-mul.js +7 -0
- package/dist/decimal/decimal-mul.js.map +1 -0
- package/dist/decimal/decimal-neg.d.ts +4 -0
- package/dist/decimal/decimal-neg.d.ts.map +1 -0
- package/dist/decimal/decimal-neg.js +9 -0
- package/dist/decimal/decimal-neg.js.map +1 -0
- package/dist/decimal/decimal-round-to-context.d.ts +9 -0
- package/dist/decimal/decimal-round-to-context.d.ts.map +1 -0
- package/dist/decimal/decimal-round-to-context.js +22 -0
- package/dist/decimal/decimal-round-to-context.js.map +1 -0
- package/dist/decimal/decimal-round-to-place.d.ts +20 -0
- package/dist/decimal/decimal-round-to-place.d.ts.map +1 -0
- package/dist/decimal/decimal-round-to-place.js +32 -0
- package/dist/decimal/decimal-round-to-place.js.map +1 -0
- package/dist/decimal/decimal-sign.d.ts +5 -0
- package/dist/decimal/decimal-sign.d.ts.map +1 -0
- package/dist/decimal/decimal-sign.js +8 -0
- package/dist/decimal/decimal-sign.js.map +1 -0
- package/dist/decimal/decimal-sqrt.d.ts +11 -0
- package/dist/decimal/decimal-sqrt.d.ts.map +1 -0
- package/dist/decimal/decimal-sqrt.js +42 -0
- package/dist/decimal/decimal-sqrt.js.map +1 -0
- package/dist/decimal/decimal-sub.d.ts +4 -0
- package/dist/decimal/decimal-sub.d.ts.map +1 -0
- package/dist/decimal/decimal-sub.js +7 -0
- package/dist/decimal/decimal-sub.js.map +1 -0
- package/dist/decimal/decimal-to-exponential.d.ts +18 -0
- package/dist/decimal/decimal-to-exponential.d.ts.map +1 -0
- package/dist/decimal/decimal-to-exponential.js +41 -0
- package/dist/decimal/decimal-to-exponential.js.map +1 -0
- package/dist/decimal/decimal-to-fixed.d.ts +20 -0
- package/dist/decimal/decimal-to-fixed.d.ts.map +1 -0
- package/dist/decimal/decimal-to-fixed.js +39 -0
- package/dist/decimal/decimal-to-fixed.js.map +1 -0
- package/dist/decimal/decimal-to-number.d.ts +4 -0
- package/dist/decimal/decimal-to-number.d.ts.map +1 -0
- package/dist/decimal/decimal-to-number.js +5 -0
- package/dist/decimal/decimal-to-number.js.map +1 -0
- package/dist/decimal/decimal-to-precision.d.ts +19 -0
- package/dist/decimal/decimal-to-precision.d.ts.map +1 -0
- package/dist/decimal/decimal-to-precision.js +35 -0
- package/dist/decimal/decimal-to-precision.js.map +1 -0
- package/dist/decimal/decimal-to-string.d.ts +28 -0
- package/dist/decimal/decimal-to-string.d.ts.map +1 -0
- package/dist/decimal/decimal-to-string.js +64 -0
- package/dist/decimal/decimal-to-string.js.map +1 -0
- package/dist/decimal/decimal-types.d.ts +54 -0
- package/dist/decimal/decimal-types.d.ts.map +1 -0
- package/dist/decimal/decimal-types.js +45 -0
- package/dist/decimal/decimal-types.js.map +1 -0
- package/dist/format-numeral.d.ts +42 -0
- package/dist/format-numeral.d.ts.map +1 -0
- package/dist/format-numeral.js +80 -0
- package/dist/format-numeral.js.map +1 -0
- package/dist/globals.d.ts +38 -0
- package/dist/globals.d.ts.map +1 -0
- package/dist/globals.js +22 -0
- package/dist/globals.js.map +1 -0
- package/dist/ieee754/binary/_all-ones-exp.d.ts +4 -0
- package/dist/ieee754/binary/_all-ones-exp.d.ts.map +1 -0
- package/dist/ieee754/binary/_all-ones-exp.js +6 -0
- package/dist/ieee754/binary/_all-ones-exp.js.map +1 -0
- package/dist/ieee754/binary/_bias.d.ts +7 -0
- package/dist/ieee754/binary/_bias.d.ts.map +1 -0
- package/dist/ieee754/binary/_bias.js +8 -0
- package/dist/ieee754/binary/_bias.js.map +1 -0
- package/dist/ieee754/binary/_encode-big-int.d.ts +11 -0
- package/dist/ieee754/binary/_encode-big-int.d.ts.map +1 -0
- package/dist/ieee754/binary/_encode-big-int.js +28 -0
- package/dist/ieee754/binary/_encode-big-int.js.map +1 -0
- package/dist/ieee754/binary/_encode-exp-sign.d.ts +11 -0
- package/dist/ieee754/binary/_encode-exp-sign.d.ts.map +1 -0
- package/dist/ieee754/binary/_encode-exp-sign.js +32 -0
- package/dist/ieee754/binary/_encode-exp-sign.js.map +1 -0
- package/dist/ieee754/binary/_encode-limbs.d.ts +8 -0
- package/dist/ieee754/binary/_encode-limbs.d.ts.map +1 -0
- package/dist/ieee754/binary/_encode-limbs.js +21 -0
- package/dist/ieee754/binary/_encode-limbs.js.map +1 -0
- package/dist/ieee754/binary/_exponent-width.d.ts +9 -0
- package/dist/ieee754/binary/_exponent-width.d.ts.map +1 -0
- package/dist/ieee754/binary/_exponent-width.js +10 -0
- package/dist/ieee754/binary/_exponent-width.js.map +1 -0
- package/dist/ieee754/binary/_finite-or-special.d.ts +8 -0
- package/dist/ieee754/binary/_finite-or-special.d.ts.map +1 -0
- package/dist/ieee754/binary/_finite-or-special.js +17 -0
- package/dist/ieee754/binary/_finite-or-special.js.map +1 -0
- package/dist/ieee754/binary/_finite-to-big-int.d.ts +8 -0
- package/dist/ieee754/binary/_finite-to-big-int.d.ts.map +1 -0
- package/dist/ieee754/binary/_finite-to-big-int.js +13 -0
- package/dist/ieee754/binary/_finite-to-big-int.js.map +1 -0
- package/dist/ieee754/binary/_finite-to-limbs.d.ts +7 -0
- package/dist/ieee754/binary/_finite-to-limbs.d.ts.map +1 -0
- package/dist/ieee754/binary/_finite-to-limbs.js +12 -0
- package/dist/ieee754/binary/_finite-to-limbs.js.map +1 -0
- package/dist/ieee754/binary/_get-biased-exp.d.ts +13 -0
- package/dist/ieee754/binary/_get-biased-exp.d.ts.map +1 -0
- package/dist/ieee754/binary/_get-biased-exp.js +26 -0
- package/dist/ieee754/binary/_get-biased-exp.js.map +1 -0
- package/dist/ieee754/binary/_get-sign.d.ts +5 -0
- package/dist/ieee754/binary/_get-sign.d.ts.map +1 -0
- package/dist/ieee754/binary/_get-sign.js +6 -0
- package/dist/ieee754/binary/_get-sign.js.map +1 -0
- package/dist/ieee754/binary/_get-trailing-sig-big-int.d.ts +9 -0
- package/dist/ieee754/binary/_get-trailing-sig-big-int.d.ts.map +1 -0
- package/dist/ieee754/binary/_get-trailing-sig-big-int.js +24 -0
- package/dist/ieee754/binary/_get-trailing-sig-big-int.js.map +1 -0
- package/dist/ieee754/binary/_get-trailing-sig-limbs.d.ts +9 -0
- package/dist/ieee754/binary/_get-trailing-sig-limbs.d.ts.map +1 -0
- package/dist/ieee754/binary/_get-trailing-sig-limbs.js +22 -0
- package/dist/ieee754/binary/_get-trailing-sig-limbs.js.map +1 -0
- package/dist/ieee754/binary/_narrow-to-big-int.d.ts +7 -0
- package/dist/ieee754/binary/_narrow-to-big-int.d.ts.map +1 -0
- package/dist/ieee754/binary/_narrow-to-big-int.js +9 -0
- package/dist/ieee754/binary/_narrow-to-big-int.js.map +1 -0
- package/dist/ieee754/binary/_normalize.d.ts +47 -0
- package/dist/ieee754/binary/_normalize.d.ts.map +1 -0
- package/dist/ieee754/binary/_normalize.js +105 -0
- package/dist/ieee754/binary/_normalize.js.map +1 -0
- package/dist/ieee754/binary/_pack-from-big-int.d.ts +13 -0
- package/dist/ieee754/binary/_pack-from-big-int.d.ts.map +1 -0
- package/dist/ieee754/binary/_pack-from-big-int.js +68 -0
- package/dist/ieee754/binary/_pack-from-big-int.js.map +1 -0
- package/dist/ieee754/binary/_pack-from-limbs.d.ts +9 -0
- package/dist/ieee754/binary/_pack-from-limbs.d.ts.map +1 -0
- package/dist/ieee754/binary/_pack-from-limbs.js +67 -0
- package/dist/ieee754/binary/_pack-from-limbs.js.map +1 -0
- package/dist/ieee754/binary/_to-format.d.ts +12 -0
- package/dist/ieee754/binary/_to-format.d.ts.map +1 -0
- package/dist/ieee754/binary/_to-format.js +20 -0
- package/dist/ieee754/binary/_to-format.js.map +1 -0
- package/dist/ieee754/binary/_trailing-width.d.ts +7 -0
- package/dist/ieee754/binary/_trailing-width.d.ts.map +1 -0
- package/dist/ieee754/binary/_trailing-width.js +8 -0
- package/dist/ieee754/binary/_trailing-width.js.map +1 -0
- package/dist/ieee754/binary/_unpack-to-big-int.d.ts +21 -0
- package/dist/ieee754/binary/_unpack-to-big-int.d.ts.map +1 -0
- package/dist/ieee754/binary/_unpack-to-big-int.js +56 -0
- package/dist/ieee754/binary/_unpack-to-big-int.js.map +1 -0
- package/dist/ieee754/binary/_unpack-to-limbs.d.ts +10 -0
- package/dist/ieee754/binary/_unpack-to-limbs.d.ts.map +1 -0
- package/dist/ieee754/binary/_unpack-to-limbs.js +46 -0
- package/dist/ieee754/binary/_unpack-to-limbs.js.map +1 -0
- package/dist/ieee754/binary/ieee-binary-abs.d.ts +4 -0
- package/dist/ieee754/binary/ieee-binary-abs.d.ts.map +1 -0
- package/dist/ieee754/binary/ieee-binary-abs.js +9 -0
- package/dist/ieee754/binary/ieee-binary-abs.js.map +1 -0
- package/dist/ieee754/binary/ieee-binary-add.d.ts +10 -0
- package/dist/ieee754/binary/ieee-binary-add.d.ts.map +1 -0
- package/dist/ieee754/binary/ieee-binary-add.js +125 -0
- package/dist/ieee754/binary/ieee-binary-add.js.map +1 -0
- package/dist/ieee754/binary/ieee-binary-cmp.d.ts +10 -0
- package/dist/ieee754/binary/ieee-binary-cmp.d.ts.map +1 -0
- package/dist/ieee754/binary/ieee-binary-cmp.js +44 -0
- package/dist/ieee754/binary/ieee-binary-cmp.js.map +1 -0
- package/dist/ieee754/binary/ieee-binary-from-decimal.d.ts +19 -0
- package/dist/ieee754/binary/ieee-binary-from-decimal.d.ts.map +1 -0
- package/dist/ieee754/binary/ieee-binary-from-decimal.js +39 -0
- package/dist/ieee754/binary/ieee-binary-from-decimal.js.map +1 -0
- package/dist/ieee754/binary/ieee-binary-from-number.d.ts +10 -0
- package/dist/ieee754/binary/ieee-binary-from-number.d.ts.map +1 -0
- package/dist/ieee754/binary/ieee-binary-from-number.js +23 -0
- package/dist/ieee754/binary/ieee-binary-from-number.js.map +1 -0
- package/dist/ieee754/binary/ieee-binary-is-finite.d.ts +11 -0
- package/dist/ieee754/binary/ieee-binary-is-finite.d.ts.map +1 -0
- package/dist/ieee754/binary/ieee-binary-is-finite.js +12 -0
- package/dist/ieee754/binary/ieee-binary-is-finite.js.map +1 -0
- package/dist/ieee754/binary/ieee-binary-is-infinite.d.ts +9 -0
- package/dist/ieee754/binary/ieee-binary-is-infinite.d.ts.map +1 -0
- package/dist/ieee754/binary/ieee-binary-is-infinite.js +10 -0
- package/dist/ieee754/binary/ieee-binary-is-infinite.js.map +1 -0
- package/dist/ieee754/binary/ieee-binary-is-nan.d.ts +12 -0
- package/dist/ieee754/binary/ieee-binary-is-nan.d.ts.map +1 -0
- package/dist/ieee754/binary/ieee-binary-is-nan.js +13 -0
- package/dist/ieee754/binary/ieee-binary-is-nan.js.map +1 -0
- package/dist/ieee754/binary/ieee-binary-neg.d.ts +4 -0
- package/dist/ieee754/binary/ieee-binary-neg.d.ts.map +1 -0
- package/dist/ieee754/binary/ieee-binary-neg.js +10 -0
- package/dist/ieee754/binary/ieee-binary-neg.js.map +1 -0
- package/dist/ieee754/binary/ieee-binary-normalize.d.ts +13 -0
- package/dist/ieee754/binary/ieee-binary-normalize.d.ts.map +1 -0
- package/dist/ieee754/binary/ieee-binary-normalize.js +14 -0
- package/dist/ieee754/binary/ieee-binary-normalize.js.map +1 -0
- package/dist/ieee754/binary/ieee-binary-sign.d.ts +19 -0
- package/dist/ieee754/binary/ieee-binary-sign.d.ts.map +1 -0
- package/dist/ieee754/binary/ieee-binary-sign.js +25 -0
- package/dist/ieee754/binary/ieee-binary-sign.js.map +1 -0
- package/dist/ieee754/binary/ieee-binary-sqrt.d.ts +17 -0
- package/dist/ieee754/binary/ieee-binary-sqrt.d.ts.map +1 -0
- package/dist/ieee754/binary/ieee-binary-sqrt.js +56 -0
- package/dist/ieee754/binary/ieee-binary-sqrt.js.map +1 -0
- package/dist/ieee754/binary/ieee-binary-sub.d.ts +5 -0
- package/dist/ieee754/binary/ieee-binary-sub.d.ts.map +1 -0
- package/dist/ieee754/binary/ieee-binary-sub.js +7 -0
- package/dist/ieee754/binary/ieee-binary-sub.js.map +1 -0
- package/dist/ieee754/binary/ieee-binary-to-decimal.d.ts +21 -0
- package/dist/ieee754/binary/ieee-binary-to-decimal.d.ts.map +1 -0
- package/dist/ieee754/binary/ieee-binary-to-decimal.js +28 -0
- package/dist/ieee754/binary/ieee-binary-to-decimal.js.map +1 -0
- package/dist/ieee754/binary/ieee-binary-to-number.d.ts +14 -0
- package/dist/ieee754/binary/ieee-binary-to-number.d.ts.map +1 -0
- package/dist/ieee754/binary/ieee-binary-to-number.js +30 -0
- package/dist/ieee754/binary/ieee-binary-to-number.js.map +1 -0
- package/dist/ieee754/binary/ieee-binary-to-shortest-decimal.d.ts +34 -0
- package/dist/ieee754/binary/ieee-binary-to-shortest-decimal.d.ts.map +1 -0
- package/dist/ieee754/binary/ieee-binary-to-shortest-decimal.js +108 -0
- package/dist/ieee754/binary/ieee-binary-to-shortest-decimal.js.map +1 -0
- package/dist/ieee754/binary/ieee-binary-to-string.d.ts +25 -0
- package/dist/ieee754/binary/ieee-binary-to-string.d.ts.map +1 -0
- package/dist/ieee754/binary/ieee-binary-to-string.js +48 -0
- package/dist/ieee754/binary/ieee-binary-to-string.js.map +1 -0
- package/dist/ieee754/binary/ieee-binary-types.d.ts +39 -0
- package/dist/ieee754/binary/ieee-binary-types.d.ts.map +1 -0
- package/dist/ieee754/binary/ieee-binary-types.js +6 -0
- package/dist/ieee754/binary/ieee-binary-types.js.map +1 -0
- package/dist/ieee754/binary/kernels/fallback/_axpby-batch.d.ts +4 -0
- package/dist/ieee754/binary/kernels/fallback/_axpby-batch.d.ts.map +1 -0
- package/dist/ieee754/binary/kernels/fallback/_axpby-batch.js +11 -0
- package/dist/ieee754/binary/kernels/fallback/_axpby-batch.js.map +1 -0
- package/dist/ieee754/binary/kernels/fallback/_axpby.d.ts +8 -0
- package/dist/ieee754/binary/kernels/fallback/_axpby.d.ts.map +1 -0
- package/dist/ieee754/binary/kernels/fallback/_axpby.js +10 -0
- package/dist/ieee754/binary/kernels/fallback/_axpby.js.map +1 -0
- package/dist/ieee754/binary/kernels/fallback/_axpy-batch.d.ts +4 -0
- package/dist/ieee754/binary/kernels/fallback/_axpy-batch.d.ts.map +1 -0
- package/dist/ieee754/binary/kernels/fallback/_axpy-batch.js +10 -0
- package/dist/ieee754/binary/kernels/fallback/_axpy-batch.js.map +1 -0
- package/dist/ieee754/binary/kernels/fallback/_axpy.d.ts +8 -0
- package/dist/ieee754/binary/kernels/fallback/_axpy.d.ts.map +1 -0
- package/dist/ieee754/binary/kernels/fallback/_axpy.js +10 -0
- package/dist/ieee754/binary/kernels/fallback/_axpy.js.map +1 -0
- package/dist/ieee754/binary/kernels/fallback/_batch-element.d.ts +13 -0
- package/dist/ieee754/binary/kernels/fallback/_batch-element.d.ts.map +1 -0
- package/dist/ieee754/binary/kernels/fallback/_batch-element.js +22 -0
- package/dist/ieee754/binary/kernels/fallback/_batch-element.js.map +1 -0
- package/dist/ieee754/binary/kernels/fallback/_div-batch.d.ts +4 -0
- package/dist/ieee754/binary/kernels/fallback/_div-batch.d.ts.map +1 -0
- package/dist/ieee754/binary/kernels/fallback/_div-batch.js +9 -0
- package/dist/ieee754/binary/kernels/fallback/_div-batch.js.map +1 -0
- package/dist/ieee754/binary/kernels/fallback/_div.d.ts +11 -0
- package/dist/ieee754/binary/kernels/fallback/_div.d.ts.map +1 -0
- package/dist/ieee754/binary/kernels/fallback/_div.js +46 -0
- package/dist/ieee754/binary/kernels/fallback/_div.js.map +1 -0
- package/dist/ieee754/binary/kernels/fallback/_mul-batch.d.ts +7 -0
- package/dist/ieee754/binary/kernels/fallback/_mul-batch.d.ts.map +1 -0
- package/dist/ieee754/binary/kernels/fallback/_mul-batch.js +12 -0
- package/dist/ieee754/binary/kernels/fallback/_mul-batch.js.map +1 -0
- package/dist/ieee754/binary/kernels/fallback/_mul.d.ts +11 -0
- package/dist/ieee754/binary/kernels/fallback/_mul.d.ts.map +1 -0
- package/dist/ieee754/binary/kernels/fallback/_mul.js +38 -0
- package/dist/ieee754/binary/kernels/fallback/_mul.js.map +1 -0
- package/dist/ieee754/binary/kernels/fallback/fallback-kernel.d.ts +24 -0
- package/dist/ieee754/binary/kernels/fallback/fallback-kernel.d.ts.map +1 -0
- package/dist/ieee754/binary/kernels/fallback/fallback-kernel.js +23 -0
- package/dist/ieee754/binary/kernels/fallback/fallback-kernel.js.map +1 -0
- package/dist/ieee754/binary/kernels/kernel.d.ts +20 -0
- package/dist/ieee754/binary/kernels/kernel.d.ts.map +1 -0
- package/dist/ieee754/binary/kernels/kernel.js +30 -0
- package/dist/ieee754/binary/kernels/kernel.js.map +1 -0
- package/dist/ieee754/binary/kernels/types.d.ts +63 -0
- package/dist/ieee754/binary/kernels/types.d.ts.map +1 -0
- package/dist/ieee754/binary/kernels/types.js +2 -0
- package/dist/ieee754/binary/kernels/types.js.map +1 -0
- package/dist/ieee754/binary/kernels/wasm/_wasm-bytes.generated.d.ts +3 -0
- package/dist/ieee754/binary/kernels/wasm/_wasm-bytes.generated.d.ts.map +1 -0
- package/dist/ieee754/binary/kernels/wasm/_wasm-bytes.generated.js +3 -0
- package/dist/ieee754/binary/kernels/wasm/_wasm-bytes.generated.js.map +1 -0
- package/dist/ieee754/binary/kernels/wasm/wasm-kernel.d.ts +29 -0
- package/dist/ieee754/binary/kernels/wasm/wasm-kernel.d.ts.map +1 -0
- package/dist/ieee754/binary/kernels/wasm/wasm-kernel.js +91 -0
- package/dist/ieee754/binary/kernels/wasm/wasm-kernel.js.map +1 -0
- package/dist/ieee754/common/_neg-sign.d.ts +4 -0
- package/dist/ieee754/common/_neg-sign.d.ts.map +1 -0
- package/dist/ieee754/common/_neg-sign.js +5 -0
- package/dist/ieee754/common/_neg-sign.js.map +1 -0
- package/dist/ieee754/common/ieee-sign.d.ts +2 -0
- package/dist/ieee754/common/ieee-sign.d.ts.map +1 -0
- package/dist/ieee754/common/ieee-sign.js +2 -0
- package/dist/ieee754/common/ieee-sign.js.map +1 -0
- package/dist/ieee754/decimal/ieee-decimal-types.d.ts +33 -0
- package/dist/ieee754/decimal/ieee-decimal-types.d.ts.map +1 -0
- package/dist/ieee754/decimal/ieee-decimal-types.js +2 -0
- package/dist/ieee754/decimal/ieee-decimal-types.js.map +1 -0
- package/dist/ieee754/ieee-format.d.ts +30 -0
- package/dist/ieee754/ieee-format.d.ts.map +1 -0
- package/dist/ieee754/ieee-format.js +59 -0
- package/dist/ieee754/ieee-format.js.map +1 -0
- package/dist/index.d.ts +93 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +93 -0
- package/dist/index.js.map +1 -0
- package/dist/integral-fractional.d.ts +83 -0
- package/dist/integral-fractional.d.ts.map +1 -0
- package/dist/integral-fractional.js +112 -0
- package/dist/integral-fractional.js.map +1 -0
- package/dist/num/_binary-fp-base.d.ts +49 -0
- package/dist/num/_binary-fp-base.d.ts.map +1 -0
- package/dist/num/_binary-fp-base.js +26 -0
- package/dist/num/_binary-fp-base.js.map +1 -0
- package/dist/num/_factory.d.ts +23 -0
- package/dist/num/_factory.d.ts.map +1 -0
- package/dist/num/_factory.js +36 -0
- package/dist/num/_factory.js.map +1 -0
- package/dist/num/_promote.d.ts +26 -0
- package/dist/num/_promote.d.ts.map +1 -0
- package/dist/num/_promote.js +38 -0
- package/dist/num/_promote.js.map +1 -0
- package/dist/num/_special-value.d.ts +76 -0
- package/dist/num/_special-value.d.ts.map +1 -0
- package/dist/num/_special-value.js +108 -0
- package/dist/num/_special-value.js.map +1 -0
- package/dist/num/binary-fp.d.ts +135 -0
- package/dist/num/binary-fp.d.ts.map +1 -0
- package/dist/num/binary-fp.js +330 -0
- package/dist/num/binary-fp.js.map +1 -0
- package/dist/num/binary-fp128.d.ts +143 -0
- package/dist/num/binary-fp128.d.ts.map +1 -0
- package/dist/num/binary-fp128.js +265 -0
- package/dist/num/binary-fp128.js.map +1 -0
- package/dist/num/binary-fp16.d.ts +131 -0
- package/dist/num/binary-fp16.d.ts.map +1 -0
- package/dist/num/binary-fp16.js +262 -0
- package/dist/num/binary-fp16.js.map +1 -0
- package/dist/num/binary-fp32.d.ts +131 -0
- package/dist/num/binary-fp32.d.ts.map +1 -0
- package/dist/num/binary-fp32.js +254 -0
- package/dist/num/binary-fp32.js.map +1 -0
- package/dist/num/binary-fp64.d.ts +140 -0
- package/dist/num/binary-fp64.d.ts.map +1 -0
- package/dist/num/binary-fp64.js +262 -0
- package/dist/num/binary-fp64.js.map +1 -0
- package/dist/num/decimal-num.d.ts +149 -0
- package/dist/num/decimal-num.d.ts.map +1 -0
- package/dist/num/decimal-num.js +275 -0
- package/dist/num/decimal-num.js.map +1 -0
- package/dist/num/fraction.d.ts +138 -0
- package/dist/num/fraction.d.ts.map +1 -0
- package/dist/num/fraction.js +299 -0
- package/dist/num/fraction.js.map +1 -0
- package/dist/num/ibitwise.d.ts +23 -0
- package/dist/num/ibitwise.d.ts.map +1 -0
- package/dist/num/ibitwise.js +2 -0
- package/dist/num/ibitwise.js.map +1 -0
- package/dist/num/integer-num.d.ts +268 -0
- package/dist/num/integer-num.d.ts.map +1 -0
- package/dist/num/integer-num.js +471 -0
- package/dist/num/integer-num.js.map +1 -0
- package/dist/num/inum.d.ts +125 -0
- package/dist/num/inum.d.ts.map +1 -0
- package/dist/num/inum.js +2 -0
- package/dist/num/inum.js.map +1 -0
- package/dist/overflow-mode.d.ts +17 -0
- package/dist/overflow-mode.d.ts.map +1 -0
- package/dist/overflow-mode.js +8 -0
- package/dist/overflow-mode.js.map +1 -0
- package/dist/precision-kind.d.ts +85 -0
- package/dist/precision-kind.d.ts.map +1 -0
- package/dist/precision-kind.js +9 -0
- package/dist/precision-kind.js.map +1 -0
- package/dist/rational/rational-abs.d.ts +4 -0
- package/dist/rational/rational-abs.d.ts.map +1 -0
- package/dist/rational/rational-abs.js +6 -0
- package/dist/rational/rational-abs.js.map +1 -0
- package/dist/rational/rational-add.d.ts +10 -0
- package/dist/rational/rational-add.d.ts.map +1 -0
- package/dist/rational/rational-add.js +28 -0
- package/dist/rational/rational-add.js.map +1 -0
- package/dist/rational/rational-compare.d.ts +10 -0
- package/dist/rational/rational-compare.d.ts.map +1 -0
- package/dist/rational/rational-compare.js +15 -0
- package/dist/rational/rational-compare.js.map +1 -0
- package/dist/rational/rational-decimal-precision.d.ts +10 -0
- package/dist/rational/rational-decimal-precision.d.ts.map +1 -0
- package/dist/rational/rational-decimal-precision.js +18 -0
- package/dist/rational/rational-decimal-precision.js.map +1 -0
- package/dist/rational/rational-div.d.ts +8 -0
- package/dist/rational/rational-div.d.ts.map +1 -0
- package/dist/rational/rational-div.js +11 -0
- package/dist/rational/rational-div.js.map +1 -0
- package/dist/rational/rational-format.d.ts +21 -0
- package/dist/rational/rational-format.d.ts.map +1 -0
- package/dist/rational/rational-format.js +36 -0
- package/dist/rational/rational-format.js.map +1 -0
- package/dist/rational/rational-fractional-precision.d.ts +16 -0
- package/dist/rational/rational-fractional-precision.d.ts.map +1 -0
- package/dist/rational/rational-fractional-precision.js +37 -0
- package/dist/rational/rational-fractional-precision.js.map +1 -0
- package/dist/rational/rational-from-number.d.ts +10 -0
- package/dist/rational/rational-from-number.d.ts.map +1 -0
- package/dist/rational/rational-from-number.js +51 -0
- package/dist/rational/rational-from-number.js.map +1 -0
- package/dist/rational/rational-integral-fractional.d.ts +10 -0
- package/dist/rational/rational-integral-fractional.d.ts.map +1 -0
- package/dist/rational/rational-integral-fractional.js +16 -0
- package/dist/rational/rational-integral-fractional.js.map +1 -0
- package/dist/rational/rational-inv.d.ts +8 -0
- package/dist/rational/rational-inv.d.ts.map +1 -0
- package/dist/rational/rational-inv.js +23 -0
- package/dist/rational/rational-inv.js.map +1 -0
- package/dist/rational/rational-is-equal.d.ts +4 -0
- package/dist/rational/rational-is-equal.d.ts.map +1 -0
- package/dist/rational/rational-is-equal.js +6 -0
- package/dist/rational/rational-is-equal.js.map +1 -0
- package/dist/rational/rational-mul.d.ts +9 -0
- package/dist/rational/rational-mul.d.ts.map +1 -0
- package/dist/rational/rational-mul.js +24 -0
- package/dist/rational/rational-mul.js.map +1 -0
- package/dist/rational/rational-neg.d.ts +4 -0
- package/dist/rational/rational-neg.d.ts.map +1 -0
- package/dist/rational/rational-neg.js +5 -0
- package/dist/rational/rational-neg.js.map +1 -0
- package/dist/rational/rational-normalize.d.ts +13 -0
- package/dist/rational/rational-normalize.d.ts.map +1 -0
- package/dist/rational/rational-normalize.js +24 -0
- package/dist/rational/rational-normalize.js.map +1 -0
- package/dist/rational/rational-reduce.d.ts +4 -0
- package/dist/rational/rational-reduce.d.ts.map +1 -0
- package/dist/rational/rational-reduce.js +17 -0
- package/dist/rational/rational-reduce.js.map +1 -0
- package/dist/rational/rational-sign.d.ts +5 -0
- package/dist/rational/rational-sign.d.ts.map +1 -0
- package/dist/rational/rational-sign.js +8 -0
- package/dist/rational/rational-sign.js.map +1 -0
- package/dist/rational/rational-sqrt-exact.d.ts +10 -0
- package/dist/rational/rational-sqrt-exact.d.ts.map +1 -0
- package/dist/rational/rational-sqrt-exact.js +22 -0
- package/dist/rational/rational-sqrt-exact.js.map +1 -0
- package/dist/rational/rational-sub.d.ts +4 -0
- package/dist/rational/rational-sub.d.ts.map +1 -0
- package/dist/rational/rational-sub.js +7 -0
- package/dist/rational/rational-sub.js.map +1 -0
- package/dist/rational/rational-to-decimal-string.d.ts +21 -0
- package/dist/rational/rational-to-decimal-string.d.ts.map +1 -0
- package/dist/rational/rational-to-decimal-string.js +39 -0
- package/dist/rational/rational-to-decimal-string.js.map +1 -0
- package/dist/rational/rational-to-number.d.ts +10 -0
- package/dist/rational/rational-to-number.d.ts.map +1 -0
- package/dist/rational/rational-to-number.js +25 -0
- package/dist/rational/rational-to-number.js.map +1 -0
- package/dist/rational/rational-to-string.d.ts +10 -0
- package/dist/rational/rational-to-string.d.ts.map +1 -0
- package/dist/rational/rational-to-string.js +14 -0
- package/dist/rational/rational-to-string.js.map +1 -0
- package/dist/rational/rational-types.d.ts +26 -0
- package/dist/rational/rational-types.d.ts.map +1 -0
- package/dist/rational/rational-types.js +13 -0
- package/dist/rational/rational-types.js.map +1 -0
- package/dist/refill-locale-skeleton.d.ts +25 -0
- package/dist/refill-locale-skeleton.d.ts.map +1 -0
- package/dist/refill-locale-skeleton.js +62 -0
- package/dist/refill-locale-skeleton.js.map +1 -0
- package/dist/resolve-locale-skeleton.d.ts +55 -0
- package/dist/resolve-locale-skeleton.d.ts.map +1 -0
- package/dist/resolve-locale-skeleton.js +105 -0
- package/dist/resolve-locale-skeleton.js.map +1 -0
- package/dist/rounding-mode-from-intl.d.ts +15 -0
- package/dist/rounding-mode-from-intl.d.ts.map +1 -0
- package/dist/rounding-mode-from-intl.js +28 -0
- package/dist/rounding-mode-from-intl.js.map +1 -0
- package/dist/rounding-mode.d.ts +48 -0
- package/dist/rounding-mode.d.ts.map +1 -0
- package/dist/rounding-mode.js +6 -0
- package/dist/rounding-mode.js.map +1 -0
- package/package.json +67 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rational-mul.js","sourceRoot":"","sources":["../../src/rational/rational-mul.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAIjD;;;;;GAKG;AACH,MAAM,UAAU,WAAW,CAC1B,CAAqB,EACrB,CAAqB;IAErB,MAAM,IAAI,GAAG,SAAS,CAAC,CAAC,CAAC,SAAS,EAAE,CAAC,CAAC,WAAW,CAAC,CAAC;IACnD,MAAM,KAAK,GAAG,SAAS,CAAC,CAAC,CAAC,SAAS,EAAE,CAAC,CAAC,WAAW,CAAC,CAAC;IAEpD,IAAI,IAAI,KAAK,EAAE,IAAI,KAAK,KAAK,EAAE,EAAE,CAAC;QACjC,OAAO;YACN,SAAS,EAAE,CAAC,CAAC,SAAS,GAAG,CAAC,CAAC,SAAS;YACpC,WAAW,EAAE,CAAC,CAAC,WAAW,GAAG,CAAC,CAAC,WAAW;YAC1C,OAAO,EAAE,CAAC,CAAC,OAAO,IAAI,CAAC,CAAC,OAAO;SAC/B,CAAC;IACH,CAAC;IAED,OAAO;QACN,SAAS,EAAE,CAAC,CAAC,CAAC,SAAS,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,SAAS,GAAG,KAAK,CAAC;QACvD,WAAW,EAAE,CAAC,CAAC,CAAC,WAAW,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,WAAW,GAAG,IAAI,CAAC;QAC7D,OAAO,EAAE,CAAC,CAAC,OAAO,IAAI,CAAC,CAAC,OAAO;KAC/B,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rational-neg.d.ts","sourceRoot":"","sources":["../../src/rational/rational-neg.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAE/C,YAAY;AACZ,wBAAgB,WAAW,CAAC,KAAK,EAAE,QAAQ,CAAC,QAAQ,CAAC,GAAG,QAAQ,CAE/D"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rational-neg.js","sourceRoot":"","sources":["../../src/rational/rational-neg.ts"],"names":[],"mappings":"AAEA,YAAY;AACZ,MAAM,UAAU,WAAW,CAAC,KAAyB;IACpD,OAAO,EAAE,GAAG,KAAK,EAAE,SAAS,EAAE,CAAC,KAAK,CAAC,SAAS,EAAE,CAAC;AAClD,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Rational } from "./rational-types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Builds a rational from a numerator and denominator, moving the sign onto the
|
|
4
|
+
* numerator.
|
|
5
|
+
*
|
|
6
|
+
* The result is not reduced — reduction costs a GCD, and a chain of operations
|
|
7
|
+
* only needs it once, at the end. Pass through {@link ratReduce} when lowest
|
|
8
|
+
* terms are wanted.
|
|
9
|
+
*
|
|
10
|
+
* @throws {RangeError} When `denominator` is zero.
|
|
11
|
+
*/
|
|
12
|
+
export declare function rationalNormalize(numerator: bigint, denominator?: bigint): Rational;
|
|
13
|
+
//# sourceMappingURL=rational-normalize.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rational-normalize.d.ts","sourceRoot":"","sources":["../../src/rational/rational-normalize.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAE/C;;;;;;;;;GASG;AACH,wBAAgB,iBAAiB,CAChC,SAAS,EAAE,MAAM,EACjB,WAAW,SAAK,GACd,QAAQ,CAcV"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Builds a rational from a numerator and denominator, moving the sign onto the
|
|
3
|
+
* numerator.
|
|
4
|
+
*
|
|
5
|
+
* The result is not reduced — reduction costs a GCD, and a chain of operations
|
|
6
|
+
* only needs it once, at the end. Pass through {@link ratReduce} when lowest
|
|
7
|
+
* terms are wanted.
|
|
8
|
+
*
|
|
9
|
+
* @throws {RangeError} When `denominator` is zero.
|
|
10
|
+
*/
|
|
11
|
+
export function rationalNormalize(numerator, denominator = 1n) {
|
|
12
|
+
if (denominator === 0n) {
|
|
13
|
+
throw new RangeError("Rational denominator cannot be zero");
|
|
14
|
+
}
|
|
15
|
+
if (denominator < 0n) {
|
|
16
|
+
return {
|
|
17
|
+
numerator: -numerator,
|
|
18
|
+
denominator: -denominator,
|
|
19
|
+
reduced: false,
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
return { numerator, denominator, reduced: false };
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=rational-normalize.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rational-normalize.js","sourceRoot":"","sources":["../../src/rational/rational-normalize.ts"],"names":[],"mappings":"AAEA;;;;;;;;;GASG;AACH,MAAM,UAAU,iBAAiB,CAChC,SAAiB,EACjB,WAAW,GAAG,EAAE;IAEhB,IAAI,WAAW,KAAK,EAAE,EAAE,CAAC;QACxB,MAAM,IAAI,UAAU,CAAC,qCAAqC,CAAC,CAAC;IAC7D,CAAC;IAED,IAAI,WAAW,GAAG,EAAE,EAAE,CAAC;QACtB,OAAO;YACN,SAAS,EAAE,CAAC,SAAS;YACrB,WAAW,EAAE,CAAC,WAAW;YACzB,OAAO,EAAE,KAAK;SACd,CAAC;IACH,CAAC;IAED,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;AACnD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rational-reduce.d.ts","sourceRoot":"","sources":["../../src/rational/rational-reduce.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAE/C,sDAAsD;AACtD,wBAAgB,cAAc,CAAC,KAAK,EAAE,QAAQ,CAAC,QAAQ,CAAC,GAAG,QAAQ,CAgBlE"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { bigIntGcd } from "@ac-kit/math-integer";
|
|
2
|
+
/** Returns an equivalent rational in lowest terms. */
|
|
3
|
+
export function rationalReduce(value) {
|
|
4
|
+
if (value.reduced) {
|
|
5
|
+
return value;
|
|
6
|
+
}
|
|
7
|
+
const divisor = bigIntGcd(value.numerator, value.denominator);
|
|
8
|
+
if (divisor === 1n) {
|
|
9
|
+
return { ...value, reduced: true };
|
|
10
|
+
}
|
|
11
|
+
return {
|
|
12
|
+
numerator: value.numerator / divisor,
|
|
13
|
+
denominator: value.denominator / divisor,
|
|
14
|
+
reduced: true,
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=rational-reduce.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rational-reduce.js","sourceRoot":"","sources":["../../src/rational/rational-reduce.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAIjD,sDAAsD;AACtD,MAAM,UAAU,cAAc,CAAC,KAAyB;IACvD,IAAI,KAAK,CAAC,OAAO,EAAE,CAAC;QACnB,OAAO,KAAK,CAAC;IACd,CAAC;IAED,MAAM,OAAO,GAAG,SAAS,CAAC,KAAK,CAAC,SAAS,EAAE,KAAK,CAAC,WAAW,CAAC,CAAC;IAE9D,IAAI,OAAO,KAAK,EAAE,EAAE,CAAC;QACpB,OAAO,EAAE,GAAG,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;IACpC,CAAC;IAED,OAAO;QACN,SAAS,EAAE,KAAK,CAAC,SAAS,GAAG,OAAO;QACpC,WAAW,EAAE,KAAK,CAAC,WAAW,GAAG,OAAO;QACxC,OAAO,EAAE,IAAI;KACb,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rational-sign.d.ts","sourceRoot":"","sources":["../../src/rational/rational-sign.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAE5C,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAE/C,gDAAgD;AAChD,wBAAgB,YAAY,CAAC,KAAK,EAAE,QAAQ,CAAC,QAAQ,CAAC,GAAG,IAAI,CAM5D"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rational-sign.js","sourceRoot":"","sources":["../../src/rational/rational-sign.ts"],"names":[],"mappings":"AAIA,gDAAgD;AAChD,MAAM,UAAU,YAAY,CAAC,KAAyB;IACrD,IAAI,KAAK,CAAC,SAAS,GAAG,EAAE,EAAE,CAAC;QAC1B,OAAO,CAAC,CAAC,CAAC;IACX,CAAC;IAED,OAAO,KAAK,CAAC,SAAS,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACrC,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Rational } from "./rational-types.js";
|
|
2
|
+
/**
|
|
3
|
+
* The exact square root, when both numerator and denominator of the reduced
|
|
4
|
+
* form are perfect squares — `√(4/9) = 2/3`.
|
|
5
|
+
*
|
|
6
|
+
* @returns The exact root, or `null` when it is irrational.
|
|
7
|
+
* @throws {RangeError} When `value` is negative.
|
|
8
|
+
*/
|
|
9
|
+
export declare function rationalSqrtExact(value: Readonly<Rational>): Rational | null;
|
|
10
|
+
//# sourceMappingURL=rational-sqrt-exact.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rational-sqrt-exact.d.ts","sourceRoot":"","sources":["../../src/rational/rational-sqrt-exact.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAE/C;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,QAAQ,CAAC,QAAQ,CAAC,GAAG,QAAQ,GAAG,IAAI,CAc5E"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { bigIntSqrtExact } from "@ac-kit/core";
|
|
2
|
+
import { rationalReduce } from "./rational-reduce.js";
|
|
3
|
+
/**
|
|
4
|
+
* The exact square root, when both numerator and denominator of the reduced
|
|
5
|
+
* form are perfect squares — `√(4/9) = 2/3`.
|
|
6
|
+
*
|
|
7
|
+
* @returns The exact root, or `null` when it is irrational.
|
|
8
|
+
* @throws {RangeError} When `value` is negative.
|
|
9
|
+
*/
|
|
10
|
+
export function rationalSqrtExact(value) {
|
|
11
|
+
if (value.numerator < 0n) {
|
|
12
|
+
throw new RangeError("Square root of a negative rational is not real");
|
|
13
|
+
}
|
|
14
|
+
const reduced = rationalReduce(value);
|
|
15
|
+
const numerator = bigIntSqrtExact(reduced.numerator);
|
|
16
|
+
const denominator = bigIntSqrtExact(reduced.denominator);
|
|
17
|
+
if (numerator === null || denominator === null) {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
return { numerator, denominator, reduced: true };
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=rational-sqrt-exact.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rational-sqrt-exact.js","sourceRoot":"","sources":["../../src/rational/rational-sqrt-exact.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAE/C,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAGtD;;;;;;GAMG;AACH,MAAM,UAAU,iBAAiB,CAAC,KAAyB;IAC1D,IAAI,KAAK,CAAC,SAAS,GAAG,EAAE,EAAE,CAAC;QAC1B,MAAM,IAAI,UAAU,CAAC,gDAAgD,CAAC,CAAC;IACxE,CAAC;IAED,MAAM,OAAO,GAAG,cAAc,CAAC,KAAK,CAAC,CAAC;IACtC,MAAM,SAAS,GAAG,eAAe,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IACrD,MAAM,WAAW,GAAG,eAAe,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;IAEzD,IAAI,SAAS,KAAK,IAAI,IAAI,WAAW,KAAK,IAAI,EAAE,CAAC;QAChD,OAAO,IAAI,CAAC;IACb,CAAC;IAED,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;AAClD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rational-sub.d.ts","sourceRoot":"","sources":["../../src/rational/rational-sub.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAE/C,eAAe;AACf,wBAAgB,WAAW,CAC1B,CAAC,EAAE,QAAQ,CAAC,QAAQ,CAAC,EACrB,CAAC,EAAE,QAAQ,CAAC,QAAQ,CAAC,GACnB,QAAQ,CAEV"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rational-sub.js","sourceRoot":"","sources":["../../src/rational/rational-sub.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAGhD,eAAe;AACf,MAAM,UAAU,WAAW,CAC1B,CAAqB,EACrB,CAAqB;IAErB,OAAO,WAAW,CAAC,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC;AACvC,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Rational } from "./rational-types.js";
|
|
2
|
+
/**
|
|
3
|
+
* `p/q` written out with exactly `places` decimal places.
|
|
4
|
+
*
|
|
5
|
+
* Truncated rather than rounded, then made **sticky**: when the division leaves
|
|
6
|
+
* a remainder the last digit is forced odd, so rounding this numeral to fewer
|
|
7
|
+
* places lands where rounding the exact value would. Without that, a caller
|
|
8
|
+
* that rounds afterwards rounds twice, and a truncation that happened to land
|
|
9
|
+
* on a tie breaks the wrong way.
|
|
10
|
+
*
|
|
11
|
+
* The sticky digit is why this is not simply `decimalDiv` on the two parts: it
|
|
12
|
+
* encodes "there is more below" in a form any later rounding respects.
|
|
13
|
+
*
|
|
14
|
+
* @param value The rational to expand. Its denominator is positive by
|
|
15
|
+
* invariant.
|
|
16
|
+
* @param places Decimal places to emit.
|
|
17
|
+
* @returns The numeral, with `places` digits after the point.
|
|
18
|
+
* @throws {RangeError} If `places` is not a non-negative integer.
|
|
19
|
+
*/
|
|
20
|
+
export declare function rationalToDecimalString(value: Readonly<Rational>, places: number): string;
|
|
21
|
+
//# sourceMappingURL=rational-to-decimal-string.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rational-to-decimal-string.d.ts","sourceRoot":"","sources":["../../src/rational/rational-to-decimal-string.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAE/C;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,uBAAuB,CACtC,KAAK,EAAE,QAAQ,CAAC,QAAQ,CAAC,EACzB,MAAM,EAAE,MAAM,GACZ,MAAM,CA0BR"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { bigIntAbs, bigIntPow10 } from "@ac-kit/core";
|
|
2
|
+
/**
|
|
3
|
+
* `p/q` written out with exactly `places` decimal places.
|
|
4
|
+
*
|
|
5
|
+
* Truncated rather than rounded, then made **sticky**: when the division leaves
|
|
6
|
+
* a remainder the last digit is forced odd, so rounding this numeral to fewer
|
|
7
|
+
* places lands where rounding the exact value would. Without that, a caller
|
|
8
|
+
* that rounds afterwards rounds twice, and a truncation that happened to land
|
|
9
|
+
* on a tie breaks the wrong way.
|
|
10
|
+
*
|
|
11
|
+
* The sticky digit is why this is not simply `decimalDiv` on the two parts: it
|
|
12
|
+
* encodes "there is more below" in a form any later rounding respects.
|
|
13
|
+
*
|
|
14
|
+
* @param value The rational to expand. Its denominator is positive by
|
|
15
|
+
* invariant.
|
|
16
|
+
* @param places Decimal places to emit.
|
|
17
|
+
* @returns The numeral, with `places` digits after the point.
|
|
18
|
+
* @throws {RangeError} If `places` is not a non-negative integer.
|
|
19
|
+
*/
|
|
20
|
+
export function rationalToDecimalString(value, places) {
|
|
21
|
+
if (!Number.isInteger(places) || places < 0) {
|
|
22
|
+
throw new RangeError(`rationalToDecimalString: places must be a non-negative integer, got ${places}`);
|
|
23
|
+
}
|
|
24
|
+
const { numerator, denominator } = value;
|
|
25
|
+
const negative = numerator < 0n;
|
|
26
|
+
const scaled = bigIntAbs(numerator) * bigIntPow10(places);
|
|
27
|
+
let magnitude = scaled / denominator;
|
|
28
|
+
if (scaled % denominator !== 0n) {
|
|
29
|
+
magnitude |= 1n;
|
|
30
|
+
}
|
|
31
|
+
const digits = magnitude.toString().padStart(places + 1, "0");
|
|
32
|
+
const sign = negative && magnitude !== 0n ? "-" : "";
|
|
33
|
+
if (places === 0) {
|
|
34
|
+
return sign + digits;
|
|
35
|
+
}
|
|
36
|
+
const point = digits.length - places;
|
|
37
|
+
return `${sign}${digits.slice(0, point)}.${digits.slice(point)}`;
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=rational-to-decimal-string.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rational-to-decimal-string.js","sourceRoot":"","sources":["../../src/rational/rational-to-decimal-string.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAItD;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,uBAAuB,CACtC,KAAyB,EACzB,MAAc;IAEd,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,MAAM,GAAG,CAAC,EAAE,CAAC;QAC7C,MAAM,IAAI,UAAU,CACnB,uEAAuE,MAAM,EAAE,CAC/E,CAAC;IACH,CAAC;IAED,MAAM,EAAE,SAAS,EAAE,WAAW,EAAE,GAAG,KAAK,CAAC;IACzC,MAAM,QAAQ,GAAG,SAAS,GAAG,EAAE,CAAC;IAChC,MAAM,MAAM,GAAG,SAAS,CAAC,SAAS,CAAC,GAAG,WAAW,CAAC,MAAM,CAAC,CAAC;IAC1D,IAAI,SAAS,GAAG,MAAM,GAAG,WAAW,CAAC;IAErC,IAAI,MAAM,GAAG,WAAW,KAAK,EAAE,EAAE,CAAC;QACjC,SAAS,IAAI,EAAE,CAAC;IACjB,CAAC;IAED,MAAM,MAAM,GAAG,SAAS,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,GAAG,CAAC,CAAC;IAC9D,MAAM,IAAI,GAAG,QAAQ,IAAI,SAAS,KAAK,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;IAErD,IAAI,MAAM,KAAK,CAAC,EAAE,CAAC;QAClB,OAAO,IAAI,GAAG,MAAM,CAAC;IACtB,CAAC;IAED,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,GAAG,MAAM,CAAC;IAErC,OAAO,GAAG,IAAI,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC;AAClE,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Rational } from "./rational-types.js";
|
|
2
|
+
/**
|
|
3
|
+
* The nearest binary64 approximation.
|
|
4
|
+
*
|
|
5
|
+
* Dividing the two `Number` conversions loses the value entirely once either
|
|
6
|
+
* part exceeds `Number.MAX_VALUE`, so wide operands are scaled down by their
|
|
7
|
+
* common bit length first.
|
|
8
|
+
*/
|
|
9
|
+
export declare function rationalToNumber(value: Readonly<Rational>): number;
|
|
10
|
+
//# sourceMappingURL=rational-to-number.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rational-to-number.d.ts","sourceRoot":"","sources":["../../src/rational/rational-to-number.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAE/C;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,QAAQ,CAAC,QAAQ,CAAC,GAAG,MAAM,CAsBlE"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { bigIntBitLength } from "@ac-kit/core";
|
|
2
|
+
/**
|
|
3
|
+
* The nearest binary64 approximation.
|
|
4
|
+
*
|
|
5
|
+
* Dividing the two `Number` conversions loses the value entirely once either
|
|
6
|
+
* part exceeds `Number.MAX_VALUE`, so wide operands are scaled down by their
|
|
7
|
+
* common bit length first.
|
|
8
|
+
*/
|
|
9
|
+
export function rationalToNumber(value) {
|
|
10
|
+
const numerator = Number(value.numerator);
|
|
11
|
+
const denominator = Number(value.denominator);
|
|
12
|
+
if (Number.isFinite(numerator) && Number.isFinite(denominator)) {
|
|
13
|
+
return numerator / denominator;
|
|
14
|
+
}
|
|
15
|
+
// One or both parts are past binary64's range. Dropping the same number of
|
|
16
|
+
// low bits from each leaves the quotient unchanged to within an ulp, and
|
|
17
|
+
// 1000 bits is the widest that still converts to a finite double.
|
|
18
|
+
const negative = value.numerator < 0n;
|
|
19
|
+
const magnitude = negative ? -value.numerator : value.numerator;
|
|
20
|
+
const widest = Math.max(bigIntBitLength(magnitude), bigIntBitLength(value.denominator));
|
|
21
|
+
const shift = BigInt(Math.max(widest - 1000, 0));
|
|
22
|
+
const quotient = Number(magnitude >> shift) / Number(value.denominator >> shift);
|
|
23
|
+
return negative ? -quotient : quotient;
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=rational-to-number.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rational-to-number.js","sourceRoot":"","sources":["../../src/rational/rational-to-number.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAI/C;;;;;;GAMG;AACH,MAAM,UAAU,gBAAgB,CAAC,KAAyB;IACzD,MAAM,SAAS,GAAG,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;IAC1C,MAAM,WAAW,GAAG,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;IAE9C,IAAI,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAC,IAAI,MAAM,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC;QAChE,OAAO,SAAS,GAAG,WAAW,CAAC;IAChC,CAAC;IAED,2EAA2E;IAC3E,yEAAyE;IACzE,kEAAkE;IAClE,MAAM,QAAQ,GAAG,KAAK,CAAC,SAAS,GAAG,EAAE,CAAC;IACtC,MAAM,SAAS,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,SAAS,CAAC;IAChE,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,CACtB,eAAe,CAAC,SAAS,CAAC,EAC1B,eAAe,CAAC,KAAK,CAAC,WAAW,CAAC,CAClC,CAAC;IACF,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,GAAG,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;IACjD,MAAM,QAAQ,GACb,MAAM,CAAC,SAAS,IAAI,KAAK,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,WAAW,IAAI,KAAK,CAAC,CAAC;IAEjE,OAAO,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC;AACxC,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Rational } from "./rational-types.js";
|
|
2
|
+
/**
|
|
3
|
+
* `p/q`, or just `p` when the denominator is one — exact in any radix, since
|
|
4
|
+
* both parts are integers.
|
|
5
|
+
*
|
|
6
|
+
* @param value The rational to render.
|
|
7
|
+
* @param radix The base for both parts, from 2 to 36. Defaults to 10.
|
|
8
|
+
*/
|
|
9
|
+
export declare function rationalToString(value: Readonly<Rational>, radix?: number): string;
|
|
10
|
+
//# sourceMappingURL=rational-to-string.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rational-to-string.d.ts","sourceRoot":"","sources":["../../src/rational/rational-to-string.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAE/C;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAC/B,KAAK,EAAE,QAAQ,CAAC,QAAQ,CAAC,EACzB,KAAK,CAAC,EAAE,MAAM,GACZ,MAAM,CAMR"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `p/q`, or just `p` when the denominator is one — exact in any radix, since
|
|
3
|
+
* both parts are integers.
|
|
4
|
+
*
|
|
5
|
+
* @param value The rational to render.
|
|
6
|
+
* @param radix The base for both parts, from 2 to 36. Defaults to 10.
|
|
7
|
+
*/
|
|
8
|
+
export function rationalToString(value, radix) {
|
|
9
|
+
if (value.denominator === 1n) {
|
|
10
|
+
return value.numerator.toString(radix);
|
|
11
|
+
}
|
|
12
|
+
return `${value.numerator.toString(radix)}/${value.denominator.toString(radix)}`;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=rational-to-string.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rational-to-string.js","sourceRoot":"","sources":["../../src/rational/rational-to-string.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,MAAM,UAAU,gBAAgB,CAC/B,KAAyB,EACzB,KAAc;IAEd,IAAI,KAAK,CAAC,WAAW,KAAK,EAAE,EAAE,CAAC;QAC9B,OAAO,KAAK,CAAC,SAAS,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IACxC,CAAC;IAED,OAAO,GAAG,KAAK,CAAC,SAAS,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,WAAW,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;AAClF,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* An exact rational, stored as a pair of `bigint`s.
|
|
3
|
+
*
|
|
4
|
+
* This is the arithmetic layer for ℚ: plain data plus free functions, with no
|
|
5
|
+
* class and no wrapper around the numerator and denominator. Every operation
|
|
6
|
+
* here is real work — cross-multiplication, sign normalisation, reduction by
|
|
7
|
+
* the greatest common divisor — which is what earns it a function rather than
|
|
8
|
+
* an operator.
|
|
9
|
+
*
|
|
10
|
+
* **Invariant:** `denominator > 0`. The sign lives entirely in the numerator,
|
|
11
|
+
* so comparison never has to inspect the denominator's sign. Values are not
|
|
12
|
+
* necessarily reduced; {@link ratReduce} does that, and {@link isReduced}
|
|
13
|
+
* records whether it has been done.
|
|
14
|
+
*/
|
|
15
|
+
export type Rational = {
|
|
16
|
+
numerator: bigint;
|
|
17
|
+
/** Always strictly positive. */
|
|
18
|
+
denominator: bigint;
|
|
19
|
+
/** `true` when `gcd(|numerator|, denominator) = 1` is known to hold. */
|
|
20
|
+
reduced: boolean;
|
|
21
|
+
};
|
|
22
|
+
/** `0/1`. */
|
|
23
|
+
export declare const RATIONAL_ZERO: Readonly<Rational>;
|
|
24
|
+
/** `1/1`. */
|
|
25
|
+
export declare const RATIONAL_ONE: Readonly<Rational>;
|
|
26
|
+
//# sourceMappingURL=rational-types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rational-types.d.ts","sourceRoot":"","sources":["../../src/rational/rational-types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,MAAM,MAAM,QAAQ,GAAG;IACtB,SAAS,EAAE,MAAM,CAAC;IAElB,gCAAgC;IAChC,WAAW,EAAE,MAAM,CAAC;IAEpB,wEAAwE;IACxE,OAAO,EAAE,OAAO,CAAC;CACjB,CAAC;AAEF,aAAa;AACb,eAAO,MAAM,aAAa,oBAIxB,CAAC;AAEH,aAAa;AACb,eAAO,MAAM,YAAY,oBAIvB,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/** `0/1`. */
|
|
2
|
+
export const RATIONAL_ZERO = Object.freeze({
|
|
3
|
+
numerator: 0n,
|
|
4
|
+
denominator: 1n,
|
|
5
|
+
reduced: true,
|
|
6
|
+
});
|
|
7
|
+
/** `1/1`. */
|
|
8
|
+
export const RATIONAL_ONE = Object.freeze({
|
|
9
|
+
numerator: 1n,
|
|
10
|
+
denominator: 1n,
|
|
11
|
+
reduced: true,
|
|
12
|
+
});
|
|
13
|
+
//# sourceMappingURL=rational-types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rational-types.js","sourceRoot":"","sources":["../../src/rational/rational-types.ts"],"names":[],"mappings":"AAwBA,aAAa;AACb,MAAM,CAAC,MAAM,aAAa,GAAG,MAAM,CAAC,MAAM,CAAW;IACpD,SAAS,EAAE,EAAE;IACb,WAAW,EAAE,EAAE;IACf,OAAO,EAAE,IAAI;CACb,CAAC,CAAC;AAEH,aAAa;AACb,MAAM,CAAC,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,CAAW;IACnD,SAAS,EAAE,EAAE;IACb,WAAW,EAAE,EAAE;IACf,OAAO,EAAE,IAAI;CACb,CAAC,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { LocaleNumberSkeleton } from "./resolve-locale-skeleton.js";
|
|
2
|
+
/**
|
|
3
|
+
* Re-emits an exact decimal numeral through a locale's own skeleton, for the
|
|
4
|
+
* values `Intl.NumberFormat` refuses to render in full.
|
|
5
|
+
*
|
|
6
|
+
* `Intl` caps a rendering at 100 fraction digits and 21 significant digits, so
|
|
7
|
+
* a `Decimal` or a wide binary float longer than that comes back rounded. This
|
|
8
|
+
* takes the numeral as given, maps its digits into the locale's numbering
|
|
9
|
+
* system, inserts group separators at the sizes the skeleton reports, and
|
|
10
|
+
* splices the result between the skeleton's prefix and suffix — so the output
|
|
11
|
+
* matches what `Intl` would produce if it had no cap.
|
|
12
|
+
*
|
|
13
|
+
* Nothing is rounded here. The caller has already decided how many digits to
|
|
14
|
+
* show; this only renders them.
|
|
15
|
+
*
|
|
16
|
+
* O(n) in the digit count.
|
|
17
|
+
*
|
|
18
|
+
* @param numeral A plain decimal numeral: optional `-`, digits, optional `.`
|
|
19
|
+
* and more digits. No exponent, and no separators.
|
|
20
|
+
* @param skeleton The locale's rendering, from `resolveLocaleSkeleton`.
|
|
21
|
+
* @param minusSign The locale's minus sign, which `Intl` reports per value.
|
|
22
|
+
* @returns The localized rendering.
|
|
23
|
+
*/
|
|
24
|
+
export declare function refillLocaleSkeleton(numeral: string, skeleton: LocaleNumberSkeleton, minusSign: string): string;
|
|
25
|
+
//# sourceMappingURL=refill-locale-skeleton.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"refill-locale-skeleton.d.ts","sourceRoot":"","sources":["../src/refill-locale-skeleton.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AAEpE;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,oBAAoB,CACnC,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,oBAAoB,EAC9B,SAAS,EAAE,MAAM,GACf,MAAM,CAcR"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Re-emits an exact decimal numeral through a locale's own skeleton, for the
|
|
3
|
+
* values `Intl.NumberFormat` refuses to render in full.
|
|
4
|
+
*
|
|
5
|
+
* `Intl` caps a rendering at 100 fraction digits and 21 significant digits, so
|
|
6
|
+
* a `Decimal` or a wide binary float longer than that comes back rounded. This
|
|
7
|
+
* takes the numeral as given, maps its digits into the locale's numbering
|
|
8
|
+
* system, inserts group separators at the sizes the skeleton reports, and
|
|
9
|
+
* splices the result between the skeleton's prefix and suffix — so the output
|
|
10
|
+
* matches what `Intl` would produce if it had no cap.
|
|
11
|
+
*
|
|
12
|
+
* Nothing is rounded here. The caller has already decided how many digits to
|
|
13
|
+
* show; this only renders them.
|
|
14
|
+
*
|
|
15
|
+
* O(n) in the digit count.
|
|
16
|
+
*
|
|
17
|
+
* @param numeral A plain decimal numeral: optional `-`, digits, optional `.`
|
|
18
|
+
* and more digits. No exponent, and no separators.
|
|
19
|
+
* @param skeleton The locale's rendering, from `resolveLocaleSkeleton`.
|
|
20
|
+
* @param minusSign The locale's minus sign, which `Intl` reports per value.
|
|
21
|
+
* @returns The localized rendering.
|
|
22
|
+
*/
|
|
23
|
+
export function refillLocaleSkeleton(numeral, skeleton, minusSign) {
|
|
24
|
+
const negative = numeral.startsWith("-");
|
|
25
|
+
const unsigned = negative ? numeral.slice(1) : numeral;
|
|
26
|
+
const point = unsigned.indexOf(".");
|
|
27
|
+
const integral = point === -1 ? unsigned : unsigned.slice(0, point);
|
|
28
|
+
const fractional = point === -1 ? "" : unsigned.slice(point + 1);
|
|
29
|
+
const body = groupIntegral_(integral, skeleton) +
|
|
30
|
+
(fractional === ""
|
|
31
|
+
? ""
|
|
32
|
+
: skeleton.decimalSeparator + mapDigits_(fractional, skeleton.digits));
|
|
33
|
+
return `${skeleton.prefix}${negative ? minusSign : ""}${body}${skeleton.suffix}`;
|
|
34
|
+
}
|
|
35
|
+
function groupIntegral_(integral, skeleton) {
|
|
36
|
+
const [primary, secondary] = skeleton.groupSizes;
|
|
37
|
+
if (primary === 0 ||
|
|
38
|
+
skeleton.groupSeparator === "" ||
|
|
39
|
+
// CLDR puts no separator in until the leading group is itself wide enough,
|
|
40
|
+
// which is why `pl-PL` prints `1000` but `10 000`.
|
|
41
|
+
integral.length < primary + skeleton.minimumGroupingDigits) {
|
|
42
|
+
return mapDigits_(integral, skeleton.digits);
|
|
43
|
+
}
|
|
44
|
+
const groups = [integral.slice(-primary)];
|
|
45
|
+
let remaining = integral.slice(0, -primary);
|
|
46
|
+
while (remaining.length > secondary) {
|
|
47
|
+
groups.unshift(remaining.slice(-secondary));
|
|
48
|
+
remaining = remaining.slice(0, -secondary);
|
|
49
|
+
}
|
|
50
|
+
groups.unshift(remaining);
|
|
51
|
+
return groups
|
|
52
|
+
.map((group) => mapDigits_(group, skeleton.digits))
|
|
53
|
+
.join(skeleton.groupSeparator);
|
|
54
|
+
}
|
|
55
|
+
function mapDigits_(digits, into) {
|
|
56
|
+
let mapped = "";
|
|
57
|
+
for (let index = 0; index < digits.length; index++) {
|
|
58
|
+
mapped += into[digits.charCodeAt(index) - 48] ?? digits[index];
|
|
59
|
+
}
|
|
60
|
+
return mapped;
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=refill-locale-skeleton.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"refill-locale-skeleton.js","sourceRoot":"","sources":["../src/refill-locale-skeleton.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,UAAU,oBAAoB,CACnC,OAAe,EACf,QAA8B,EAC9B,SAAiB;IAEjB,MAAM,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;IACzC,MAAM,QAAQ,GAAG,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;IACvD,MAAM,KAAK,GAAG,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IACpC,MAAM,QAAQ,GAAG,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;IACpE,MAAM,UAAU,GAAG,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC;IAEjE,MAAM,IAAI,GACT,cAAc,CAAC,QAAQ,EAAE,QAAQ,CAAC;QAClC,CAAC,UAAU,KAAK,EAAE;YACjB,CAAC,CAAC,EAAE;YACJ,CAAC,CAAC,QAAQ,CAAC,gBAAgB,GAAG,UAAU,CAAC,UAAU,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC;IAEzE,OAAO,GAAG,QAAQ,CAAC,MAAM,GAAG,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,GAAG,IAAI,GAAG,QAAQ,CAAC,MAAM,EAAE,CAAC;AAClF,CAAC;AAED,SAAS,cAAc,CACtB,QAAgB,EAChB,QAA8B;IAE9B,MAAM,CAAC,OAAO,EAAE,SAAS,CAAC,GAAG,QAAQ,CAAC,UAAU,CAAC;IAEjD,IACC,OAAO,KAAK,CAAC;QACb,QAAQ,CAAC,cAAc,KAAK,EAAE;QAC9B,2EAA2E;QAC3E,mDAAmD;QACnD,QAAQ,CAAC,MAAM,GAAG,OAAO,GAAG,QAAQ,CAAC,qBAAqB,EACzD,CAAC;QACF,OAAO,UAAU,CAAC,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;IAC9C,CAAC;IAED,MAAM,MAAM,GAAa,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC;IACpD,IAAI,SAAS,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC;IAE5C,OAAO,SAAS,CAAC,MAAM,GAAG,SAAS,EAAE,CAAC;QACrC,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC;QAC5C,SAAS,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,SAAS,CAAC,CAAC;IAC5C,CAAC;IAED,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAE1B,OAAO,MAAM;SACX,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,UAAU,CAAC,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;SAClD,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAC;AACjC,CAAC;AAED,SAAS,UAAU,CAAC,MAAc,EAAE,IAAuB;IAC1D,IAAI,MAAM,GAAG,EAAE,CAAC;IAEhB,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,CAAC;QACpD,MAAM,IAAI,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,IAAI,MAAM,CAAC,KAAK,CAAC,CAAC;IAChE,CAAC;IAED,OAAO,MAAM,CAAC;AACf,CAAC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Everything about a locale's number rendering that `Intl` does not expose as
|
|
3
|
+
* data, recovered from what it does expose: labelled parts.
|
|
4
|
+
*
|
|
5
|
+
* `Intl.NumberFormat` holds CLDR's separators, grouping sizes and digit set
|
|
6
|
+
* internally and offers no accessor for them — `resolvedOptions` reports the
|
|
7
|
+
* options it was given, not the data it resolved. `formatToParts` does label
|
|
8
|
+
* every piece of its output, though, so formatting a probe value and reading
|
|
9
|
+
* the labels back recovers the lot without a CLDR table of our own.
|
|
10
|
+
*
|
|
11
|
+
* This is only needed past `Intl`'s own limits of 100 fraction digits and 21
|
|
12
|
+
* significant digits. Inside them `Intl.NumberFormat.prototype.format` is exact
|
|
13
|
+
* and is used directly.
|
|
14
|
+
*/
|
|
15
|
+
export type LocaleNumberSkeleton = {
|
|
16
|
+
/** The ten digits of the resolved numbering system, `0` through `9`. */
|
|
17
|
+
readonly digits: readonly string[];
|
|
18
|
+
/** Character between the integral and fractional parts. */
|
|
19
|
+
readonly decimalSeparator: string;
|
|
20
|
+
/** Character between digit groups, or `""` when the locale groups none. */
|
|
21
|
+
readonly groupSeparator: string;
|
|
22
|
+
/**
|
|
23
|
+
* Digits in the group nearest the point, then in every group above it. `[3,
|
|
24
|
+
* 3]` for most locales, `[3, 2]` for `en-IN`'s `12,34,567`.
|
|
25
|
+
*/
|
|
26
|
+
readonly groupSizes: readonly [number, number];
|
|
27
|
+
/**
|
|
28
|
+
* Integral digits a value needs before grouping starts at all. `2` in `pl-PL`
|
|
29
|
+
* and `es-ES`, where `1000` is ungrouped but `10 000` is not.
|
|
30
|
+
*/
|
|
31
|
+
readonly minimumGroupingDigits: number;
|
|
32
|
+
/** Text before the number, including any sign, currency symbol or spacing. */
|
|
33
|
+
readonly prefix: string;
|
|
34
|
+
/** Text after the number, including any percent sign, unit or spacing. */
|
|
35
|
+
readonly suffix: string;
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* Learns everything about how `formatter` renders a number that is needed to
|
|
39
|
+
* re-emit one by hand.
|
|
40
|
+
*
|
|
41
|
+
* Costs three `formatToParts` calls and one `format`, so a caller rendering
|
|
42
|
+
* many values resolves it once and keeps it — which is what `formatNumeral`
|
|
43
|
+
* does.
|
|
44
|
+
*
|
|
45
|
+
* The probe is magnitude-independent by construction: separators, grouping
|
|
46
|
+
* sizes, digit set and the surrounding literals do not vary with the value. Two
|
|
47
|
+
* things do, and neither survives this treatment — compact notation (`1.2M`)
|
|
48
|
+
* and long or narrow unit names both select a CLDR pattern by magnitude and
|
|
49
|
+
* plural category, so a small probe cannot predict a large value's output.
|
|
50
|
+
*
|
|
51
|
+
* @param formatter The formatter to interrogate.
|
|
52
|
+
* @returns The recovered skeleton.
|
|
53
|
+
*/
|
|
54
|
+
export declare function resolveLocaleSkeleton(formatter: Intl.NumberFormat): LocaleNumberSkeleton;
|
|
55
|
+
//# sourceMappingURL=resolve-locale-skeleton.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolve-locale-skeleton.d.ts","sourceRoot":"","sources":["../src/resolve-locale-skeleton.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,MAAM,MAAM,oBAAoB,GAAG;IAClC,wEAAwE;IACxE,QAAQ,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC;IACnC,2DAA2D;IAC3D,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC;IAClC,2EAA2E;IAC3E,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC;;;OAGG;IACH,QAAQ,CAAC,UAAU,EAAE,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC/C;;;OAGG;IACH,QAAQ,CAAC,qBAAqB,EAAE,MAAM,CAAC;IACvC,8EAA8E;IAC9E,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,0EAA0E;IAC1E,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACxB,CAAC;AAOF;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,qBAAqB,CACpC,SAAS,EAAE,IAAI,CAAC,YAAY,GAC1B,oBAAoB,CA8CtB"}
|