@nberlette/math 0.7.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 +20 -0
- package/README.md +889 -0
- package/cjs/abs.d.ts +14 -0
- package/cjs/abs.d.ts.map +1 -0
- package/cjs/abs.js +22 -0
- package/cjs/abs.js.map +1 -0
- package/cjs/acos.d.ts +17 -0
- package/cjs/acos.d.ts.map +1 -0
- package/cjs/acos.js +27 -0
- package/cjs/acos.js.map +1 -0
- package/cjs/acosh.d.ts +11 -0
- package/cjs/acosh.d.ts.map +1 -0
- package/cjs/acosh.js +35 -0
- package/cjs/acosh.js.map +1 -0
- package/cjs/asin.d.ts +11 -0
- package/cjs/asin.d.ts.map +1 -0
- package/cjs/asin.js +28 -0
- package/cjs/asin.js.map +1 -0
- package/cjs/asinh.d.ts +9 -0
- package/cjs/asinh.d.ts.map +1 -0
- package/cjs/asinh.js +26 -0
- package/cjs/asinh.js.map +1 -0
- package/cjs/atan.d.ts +11 -0
- package/cjs/atan.d.ts.map +1 -0
- package/cjs/atan.js +65 -0
- package/cjs/atan.js.map +1 -0
- package/cjs/atan2.d.ts +12 -0
- package/cjs/atan2.d.ts.map +1 -0
- package/cjs/atan2.js +70 -0
- package/cjs/atan2.js.map +1 -0
- package/cjs/atanh.d.ts +11 -0
- package/cjs/atanh.d.ts.map +1 -0
- package/cjs/atanh.js +32 -0
- package/cjs/atanh.js.map +1 -0
- package/cjs/cbrt.d.ts +9 -0
- package/cjs/cbrt.d.ts.map +1 -0
- package/cjs/cbrt.js +26 -0
- package/cjs/cbrt.js.map +1 -0
- package/cjs/ceil.d.ts +15 -0
- package/cjs/ceil.d.ts.map +1 -0
- package/cjs/ceil.js +34 -0
- package/cjs/ceil.js.map +1 -0
- package/cjs/clamp.d.ts +15 -0
- package/cjs/clamp.d.ts.map +1 -0
- package/cjs/clamp.js +32 -0
- package/cjs/clamp.js.map +1 -0
- package/cjs/clz32.d.ts +20 -0
- package/cjs/clz32.d.ts.map +1 -0
- package/cjs/clz32.js +48 -0
- package/cjs/clz32.js.map +1 -0
- package/cjs/constants/e.d.ts +17 -0
- package/cjs/constants/e.d.ts.map +1 -0
- package/cjs/constants/e.js +19 -0
- package/cjs/constants/e.js.map +1 -0
- package/cjs/constants/epsilon.d.ts +24 -0
- package/cjs/constants/epsilon.d.ts.map +1 -0
- package/cjs/constants/epsilon.js +26 -0
- package/cjs/constants/epsilon.js.map +1 -0
- package/cjs/constants/index.d.ts +23 -0
- package/cjs/constants/index.d.ts.map +1 -0
- package/cjs/constants/index.js +39 -0
- package/cjs/constants/index.js.map +1 -0
- package/cjs/constants/infinity.d.ts +3 -0
- package/cjs/constants/infinity.d.ts.map +1 -0
- package/cjs/constants/infinity.js +19 -0
- package/cjs/constants/infinity.js.map +1 -0
- package/cjs/constants/ln10.d.ts +10 -0
- package/cjs/constants/ln10.d.ts.map +1 -0
- package/cjs/constants/ln10.js +12 -0
- package/cjs/constants/ln10.js.map +1 -0
- package/cjs/constants/ln2.d.ts +10 -0
- package/cjs/constants/ln2.d.ts.map +1 -0
- package/cjs/constants/ln2.js +12 -0
- package/cjs/constants/ln2.js.map +1 -0
- package/cjs/constants/log10e.d.ts +10 -0
- package/cjs/constants/log10e.d.ts.map +1 -0
- package/cjs/constants/log10e.js +12 -0
- package/cjs/constants/log10e.js.map +1 -0
- package/cjs/constants/log2e.d.ts +10 -0
- package/cjs/constants/log2e.d.ts.map +1 -0
- package/cjs/constants/log2e.js +12 -0
- package/cjs/constants/log2e.js.map +1 -0
- package/cjs/constants/max_safe_integer.d.ts +11 -0
- package/cjs/constants/max_safe_integer.d.ts.map +1 -0
- package/cjs/constants/max_safe_integer.js +13 -0
- package/cjs/constants/max_safe_integer.js.map +1 -0
- package/cjs/constants/max_value.d.ts +10 -0
- package/cjs/constants/max_value.d.ts.map +1 -0
- package/cjs/constants/max_value.js +12 -0
- package/cjs/constants/max_value.js.map +1 -0
- package/cjs/constants/min_safe_integer.d.ts +12 -0
- package/cjs/constants/min_safe_integer.d.ts.map +1 -0
- package/cjs/constants/min_safe_integer.js +14 -0
- package/cjs/constants/min_safe_integer.js.map +1 -0
- package/cjs/constants/min_value.d.ts +10 -0
- package/cjs/constants/min_value.d.ts.map +1 -0
- package/cjs/constants/min_value.js +12 -0
- package/cjs/constants/min_value.js.map +1 -0
- package/cjs/constants/nan.d.ts +47 -0
- package/cjs/constants/nan.d.ts.map +1 -0
- package/cjs/constants/nan.js +30 -0
- package/cjs/constants/nan.js.map +1 -0
- package/cjs/constants/negative_infinity.d.ts +28 -0
- package/cjs/constants/negative_infinity.d.ts.map +1 -0
- package/cjs/constants/negative_infinity.js +15 -0
- package/cjs/constants/negative_infinity.js.map +1 -0
- package/cjs/constants/negative_zero.d.ts +31 -0
- package/cjs/constants/negative_zero.d.ts.map +1 -0
- package/cjs/constants/negative_zero.js +21 -0
- package/cjs/constants/negative_zero.js.map +1 -0
- package/cjs/constants/pi.d.ts +10 -0
- package/cjs/constants/pi.d.ts.map +1 -0
- package/cjs/constants/pi.js +12 -0
- package/cjs/constants/pi.js.map +1 -0
- package/cjs/constants/positive_infinity.d.ts +29 -0
- package/cjs/constants/positive_infinity.d.ts.map +1 -0
- package/cjs/constants/positive_infinity.js +16 -0
- package/cjs/constants/positive_infinity.js.map +1 -0
- package/cjs/constants/positive_zero.d.ts +38 -0
- package/cjs/constants/positive_zero.d.ts.map +1 -0
- package/cjs/constants/positive_zero.js +36 -0
- package/cjs/constants/positive_zero.js.map +1 -0
- package/cjs/constants/sqrt1_2.d.ts +9 -0
- package/cjs/constants/sqrt1_2.d.ts.map +1 -0
- package/cjs/constants/sqrt1_2.js +11 -0
- package/cjs/constants/sqrt1_2.js.map +1 -0
- package/cjs/constants/sqrt2.d.ts +9 -0
- package/cjs/constants/sqrt2.d.ts.map +1 -0
- package/cjs/constants/sqrt2.js +11 -0
- package/cjs/constants/sqrt2.js.map +1 -0
- package/cjs/cos.d.ts +10 -0
- package/cjs/cos.d.ts.map +1 -0
- package/cjs/cos.js +32 -0
- package/cjs/cos.js.map +1 -0
- package/cjs/cosh.d.ts +10 -0
- package/cjs/cosh.d.ts.map +1 -0
- package/cjs/cosh.js +21 -0
- package/cjs/cosh.js.map +1 -0
- package/cjs/exp.d.ts +20 -0
- package/cjs/exp.d.ts.map +1 -0
- package/cjs/exp.js +48 -0
- package/cjs/exp.js.map +1 -0
- package/cjs/expm1.d.ts +11 -0
- package/cjs/expm1.d.ts.map +1 -0
- package/cjs/expm1.js +38 -0
- package/cjs/expm1.js.map +1 -0
- package/cjs/f16round.d.ts +24 -0
- package/cjs/f16round.d.ts.map +1 -0
- package/cjs/f16round.js +42 -0
- package/cjs/f16round.js.map +1 -0
- package/cjs/float16/constants.d.ts +97 -0
- package/cjs/float16/constants.d.ts.map +1 -0
- package/cjs/float16/constants.js +99 -0
- package/cjs/float16/constants.js.map +1 -0
- package/cjs/float16/decode.d.ts +40 -0
- package/cjs/float16/decode.d.ts.map +1 -0
- package/cjs/float16/decode.js +67 -0
- package/cjs/float16/decode.js.map +1 -0
- package/cjs/float16/encode.d.ts +67 -0
- package/cjs/float16/encode.d.ts.map +1 -0
- package/cjs/float16/encode.js +77 -0
- package/cjs/float16/encode.js.map +1 -0
- package/cjs/float16/guards.d.ts +22 -0
- package/cjs/float16/guards.d.ts.map +1 -0
- package/cjs/float16/guards.js +15 -0
- package/cjs/float16/guards.js.map +1 -0
- package/cjs/float16/index.d.ts +11 -0
- package/cjs/float16/index.d.ts.map +1 -0
- package/cjs/float16/index.js +27 -0
- package/cjs/float16/index.js.map +1 -0
- package/cjs/float16/round.d.ts +25 -0
- package/cjs/float16/round.d.ts.map +1 -0
- package/cjs/float16/round.js +46 -0
- package/cjs/float16/round.js.map +1 -0
- package/cjs/float32/constants.d.ts +96 -0
- package/cjs/float32/constants.d.ts.map +1 -0
- package/cjs/float32/constants.js +98 -0
- package/cjs/float32/constants.js.map +1 -0
- package/cjs/float32/decode.d.ts +38 -0
- package/cjs/float32/decode.d.ts.map +1 -0
- package/cjs/float32/decode.js +70 -0
- package/cjs/float32/decode.js.map +1 -0
- package/cjs/float32/encode.d.ts +50 -0
- package/cjs/float32/encode.d.ts.map +1 -0
- package/cjs/float32/encode.js +77 -0
- package/cjs/float32/encode.js.map +1 -0
- package/cjs/float32/guards.d.ts +37 -0
- package/cjs/float32/guards.d.ts.map +1 -0
- package/cjs/float32/guards.js +20 -0
- package/cjs/float32/guards.js.map +1 -0
- package/cjs/float32/index.d.ts +11 -0
- package/cjs/float32/index.d.ts.map +1 -0
- package/cjs/float32/index.js +27 -0
- package/cjs/float32/index.js.map +1 -0
- package/cjs/float32/round.d.ts +23 -0
- package/cjs/float32/round.d.ts.map +1 -0
- package/cjs/float32/round.js +36 -0
- package/cjs/float32/round.js.map +1 -0
- package/cjs/floor.d.ts +10 -0
- package/cjs/floor.d.ts.map +1 -0
- package/cjs/floor.js +32 -0
- package/cjs/floor.js.map +1 -0
- package/cjs/fround.d.ts +23 -0
- package/cjs/fround.d.ts.map +1 -0
- package/cjs/fround.js +35 -0
- package/cjs/fround.js.map +1 -0
- package/cjs/guards/finite.d.ts +23 -0
- package/cjs/guards/finite.d.ts.map +1 -0
- package/cjs/guards/finite.js +21 -0
- package/cjs/guards/finite.js.map +1 -0
- package/cjs/guards/index.d.ts +50 -0
- package/cjs/guards/index.d.ts.map +1 -0
- package/cjs/guards/index.js +66 -0
- package/cjs/guards/index.js.map +1 -0
- package/cjs/guards/infinity.d.ts +3 -0
- package/cjs/guards/infinity.d.ts.map +1 -0
- package/cjs/guards/infinity.js +19 -0
- package/cjs/guards/infinity.js.map +1 -0
- package/cjs/guards/integer.d.ts +47 -0
- package/cjs/guards/integer.d.ts.map +1 -0
- package/cjs/guards/integer.js +23 -0
- package/cjs/guards/integer.js.map +1 -0
- package/cjs/guards/nan.d.ts +61 -0
- package/cjs/guards/nan.d.ts.map +1 -0
- package/cjs/guards/nan.js +68 -0
- package/cjs/guards/nan.js.map +1 -0
- package/cjs/guards/negative_infinity.d.ts +19 -0
- package/cjs/guards/negative_infinity.d.ts.map +1 -0
- package/cjs/guards/negative_infinity.js +25 -0
- package/cjs/guards/negative_infinity.js.map +1 -0
- package/cjs/guards/negative_zero.d.ts +12 -0
- package/cjs/guards/negative_zero.d.ts.map +1 -0
- package/cjs/guards/negative_zero.js +24 -0
- package/cjs/guards/negative_zero.js.map +1 -0
- package/cjs/guards/positive_infinity.d.ts +19 -0
- package/cjs/guards/positive_infinity.d.ts.map +1 -0
- package/cjs/guards/positive_infinity.js +25 -0
- package/cjs/guards/positive_infinity.js.map +1 -0
- package/cjs/guards/positive_zero.d.ts +17 -0
- package/cjs/guards/positive_zero.d.ts.map +1 -0
- package/cjs/guards/positive_zero.js +36 -0
- package/cjs/guards/positive_zero.js.map +1 -0
- package/cjs/guards/safe_integer.d.ts +33 -0
- package/cjs/guards/safe_integer.d.ts.map +1 -0
- package/cjs/guards/safe_integer.js +27 -0
- package/cjs/guards/safe_integer.js.map +1 -0
- package/cjs/hypot.d.ts +18 -0
- package/cjs/hypot.d.ts.map +1 -0
- package/cjs/hypot.js +63 -0
- package/cjs/hypot.js.map +1 -0
- package/cjs/ieee754.d.ts +16 -0
- package/cjs/ieee754.d.ts.map +1 -0
- package/cjs/ieee754.js +32 -0
- package/cjs/ieee754.js.map +1 -0
- package/cjs/imul.d.ts +17 -0
- package/cjs/imul.d.ts.map +1 -0
- package/cjs/imul.js +24 -0
- package/cjs/imul.js.map +1 -0
- package/cjs/index.d.ts +84 -0
- package/cjs/index.d.ts.map +1 -0
- package/cjs/index.js +113 -0
- package/cjs/index.js.map +1 -0
- package/cjs/internal/ieee754.d.ts +174 -0
- package/cjs/internal/ieee754.d.ts.map +1 -0
- package/cjs/internal/ieee754.js +200 -0
- package/cjs/internal/ieee754.js.map +1 -0
- package/cjs/internal/primordials.d.ts +30 -0
- package/cjs/internal/primordials.d.ts.map +1 -0
- package/cjs/internal/primordials.js +30 -0
- package/cjs/internal/primordials.js.map +1 -0
- package/cjs/log.d.ts +9 -0
- package/cjs/log.d.ts.map +1 -0
- package/cjs/log.js +46 -0
- package/cjs/log.js.map +1 -0
- package/cjs/log10.d.ts +9 -0
- package/cjs/log10.d.ts.map +1 -0
- package/cjs/log10.js +21 -0
- package/cjs/log10.js.map +1 -0
- package/cjs/log1p.d.ts +10 -0
- package/cjs/log1p.d.ts.map +1 -0
- package/cjs/log1p.js +32 -0
- package/cjs/log1p.js.map +1 -0
- package/cjs/log2.d.ts +12 -0
- package/cjs/log2.d.ts.map +1 -0
- package/cjs/log2.js +24 -0
- package/cjs/log2.js.map +1 -0
- package/cjs/max.d.ts +22 -0
- package/cjs/max.d.ts.map +1 -0
- package/cjs/max.js +51 -0
- package/cjs/max.js.map +1 -0
- package/cjs/min.d.ts +10 -0
- package/cjs/min.d.ts.map +1 -0
- package/cjs/min.js +36 -0
- package/cjs/min.js.map +1 -0
- package/cjs/package.json +3 -0
- package/cjs/pow.d.ts +31 -0
- package/cjs/pow.d.ts.map +1 -0
- package/cjs/pow.js +36 -0
- package/cjs/pow.js.map +1 -0
- package/cjs/random.d.ts +93 -0
- package/cjs/random.d.ts.map +1 -0
- package/cjs/random.js +242 -0
- package/cjs/random.js.map +1 -0
- package/cjs/round.d.ts +9 -0
- package/cjs/round.d.ts.map +1 -0
- package/cjs/round.js +24 -0
- package/cjs/round.js.map +1 -0
- package/cjs/sign.d.ts +17 -0
- package/cjs/sign.d.ts.map +1 -0
- package/cjs/sign.js +22 -0
- package/cjs/sign.js.map +1 -0
- package/cjs/sin.d.ts +14 -0
- package/cjs/sin.d.ts.map +1 -0
- package/cjs/sin.js +31 -0
- package/cjs/sin.js.map +1 -0
- package/cjs/sinh.d.ts +14 -0
- package/cjs/sinh.d.ts.map +1 -0
- package/cjs/sinh.js +22 -0
- package/cjs/sinh.js.map +1 -0
- package/cjs/sqrt.d.ts +19 -0
- package/cjs/sqrt.d.ts.map +1 -0
- package/cjs/sqrt.js +45 -0
- package/cjs/sqrt.js.map +1 -0
- package/cjs/tan.d.ts +9 -0
- package/cjs/tan.d.ts.map +1 -0
- package/cjs/tan.js +26 -0
- package/cjs/tan.js.map +1 -0
- package/cjs/tanh.d.ts +17 -0
- package/cjs/tanh.d.ts.map +1 -0
- package/cjs/tanh.js +34 -0
- package/cjs/tanh.js.map +1 -0
- package/cjs/trunc.d.ts +21 -0
- package/cjs/trunc.d.ts.map +1 -0
- package/cjs/trunc.js +50 -0
- package/cjs/trunc.js.map +1 -0
- package/cjs/types/finite.d.ts +16 -0
- package/cjs/types/finite.d.ts.map +1 -0
- package/cjs/types/finite.js +4 -0
- package/cjs/types/finite.js.map +1 -0
- package/cjs/types/float.d.ts +65 -0
- package/cjs/types/float.d.ts.map +1 -0
- package/cjs/types/float.js +4 -0
- package/cjs/types/float.js.map +1 -0
- package/cjs/types/index.d.ts +6 -0
- package/cjs/types/index.d.ts.map +1 -0
- package/cjs/types/index.js +22 -0
- package/cjs/types/index.js.map +1 -0
- package/cjs/types/integer.d.ts +147 -0
- package/cjs/types/integer.d.ts.map +1 -0
- package/cjs/types/integer.js +5 -0
- package/cjs/types/integer.js.map +1 -0
- package/cjs/types/precision.d.ts +46 -0
- package/cjs/types/precision.d.ts.map +1 -0
- package/cjs/types/precision.js +9 -0
- package/cjs/types/precision.js.map +1 -0
- package/cjs/types/safe_integer.d.ts +17 -0
- package/cjs/types/safe_integer.d.ts.map +1 -0
- package/cjs/types/safe_integer.js +5 -0
- package/cjs/types/safe_integer.js.map +1 -0
- package/esm/abs.d.ts +14 -0
- package/esm/abs.d.ts.map +1 -0
- package/esm/abs.js +19 -0
- package/esm/abs.js.map +1 -0
- package/esm/acos.d.ts +17 -0
- package/esm/acos.d.ts.map +1 -0
- package/esm/acos.js +24 -0
- package/esm/acos.js.map +1 -0
- package/esm/acosh.d.ts +11 -0
- package/esm/acosh.d.ts.map +1 -0
- package/esm/acosh.js +32 -0
- package/esm/acosh.js.map +1 -0
- package/esm/asin.d.ts +11 -0
- package/esm/asin.d.ts.map +1 -0
- package/esm/asin.js +25 -0
- package/esm/asin.js.map +1 -0
- package/esm/asinh.d.ts +9 -0
- package/esm/asinh.d.ts.map +1 -0
- package/esm/asinh.js +23 -0
- package/esm/asinh.js.map +1 -0
- package/esm/atan.d.ts +11 -0
- package/esm/atan.d.ts.map +1 -0
- package/esm/atan.js +62 -0
- package/esm/atan.js.map +1 -0
- package/esm/atan2.d.ts +12 -0
- package/esm/atan2.d.ts.map +1 -0
- package/esm/atan2.js +67 -0
- package/esm/atan2.js.map +1 -0
- package/esm/atanh.d.ts +11 -0
- package/esm/atanh.d.ts.map +1 -0
- package/esm/atanh.js +29 -0
- package/esm/atanh.js.map +1 -0
- package/esm/cbrt.d.ts +9 -0
- package/esm/cbrt.d.ts.map +1 -0
- package/esm/cbrt.js +23 -0
- package/esm/cbrt.js.map +1 -0
- package/esm/ceil.d.ts +15 -0
- package/esm/ceil.d.ts.map +1 -0
- package/esm/ceil.js +31 -0
- package/esm/ceil.js.map +1 -0
- package/esm/clamp.d.ts +15 -0
- package/esm/clamp.d.ts.map +1 -0
- package/esm/clamp.js +29 -0
- package/esm/clamp.js.map +1 -0
- package/esm/clz32.d.ts +20 -0
- package/esm/clz32.d.ts.map +1 -0
- package/esm/clz32.js +45 -0
- package/esm/clz32.js.map +1 -0
- package/esm/constants/e.d.ts +17 -0
- package/esm/constants/e.d.ts.map +1 -0
- package/esm/constants/e.js +16 -0
- package/esm/constants/e.js.map +1 -0
- package/esm/constants/epsilon.d.ts +24 -0
- package/esm/constants/epsilon.d.ts.map +1 -0
- package/esm/constants/epsilon.js +23 -0
- package/esm/constants/epsilon.js.map +1 -0
- package/esm/constants/index.d.ts +23 -0
- package/esm/constants/index.d.ts.map +1 -0
- package/esm/constants/index.js +23 -0
- package/esm/constants/index.js.map +1 -0
- package/esm/constants/infinity.d.ts +3 -0
- package/esm/constants/infinity.d.ts.map +1 -0
- package/esm/constants/infinity.js +3 -0
- package/esm/constants/infinity.js.map +1 -0
- package/esm/constants/ln10.d.ts +10 -0
- package/esm/constants/ln10.d.ts.map +1 -0
- package/esm/constants/ln10.js +9 -0
- package/esm/constants/ln10.js.map +1 -0
- package/esm/constants/ln2.d.ts +10 -0
- package/esm/constants/ln2.d.ts.map +1 -0
- package/esm/constants/ln2.js +9 -0
- package/esm/constants/ln2.js.map +1 -0
- package/esm/constants/log10e.d.ts +10 -0
- package/esm/constants/log10e.d.ts.map +1 -0
- package/esm/constants/log10e.js +9 -0
- package/esm/constants/log10e.js.map +1 -0
- package/esm/constants/log2e.d.ts +10 -0
- package/esm/constants/log2e.d.ts.map +1 -0
- package/esm/constants/log2e.js +9 -0
- package/esm/constants/log2e.js.map +1 -0
- package/esm/constants/max_safe_integer.d.ts +11 -0
- package/esm/constants/max_safe_integer.d.ts.map +1 -0
- package/esm/constants/max_safe_integer.js +10 -0
- package/esm/constants/max_safe_integer.js.map +1 -0
- package/esm/constants/max_value.d.ts +10 -0
- package/esm/constants/max_value.d.ts.map +1 -0
- package/esm/constants/max_value.js +9 -0
- package/esm/constants/max_value.js.map +1 -0
- package/esm/constants/min_safe_integer.d.ts +12 -0
- package/esm/constants/min_safe_integer.d.ts.map +1 -0
- package/esm/constants/min_safe_integer.js +11 -0
- package/esm/constants/min_safe_integer.js.map +1 -0
- package/esm/constants/min_value.d.ts +10 -0
- package/esm/constants/min_value.d.ts.map +1 -0
- package/esm/constants/min_value.js +9 -0
- package/esm/constants/min_value.js.map +1 -0
- package/esm/constants/nan.d.ts +47 -0
- package/esm/constants/nan.d.ts.map +1 -0
- package/esm/constants/nan.js +27 -0
- package/esm/constants/nan.js.map +1 -0
- package/esm/constants/negative_infinity.d.ts +28 -0
- package/esm/constants/negative_infinity.d.ts.map +1 -0
- package/esm/constants/negative_infinity.js +12 -0
- package/esm/constants/negative_infinity.js.map +1 -0
- package/esm/constants/negative_zero.d.ts +31 -0
- package/esm/constants/negative_zero.d.ts.map +1 -0
- package/esm/constants/negative_zero.js +18 -0
- package/esm/constants/negative_zero.js.map +1 -0
- package/esm/constants/pi.d.ts +10 -0
- package/esm/constants/pi.d.ts.map +1 -0
- package/esm/constants/pi.js +9 -0
- package/esm/constants/pi.js.map +1 -0
- package/esm/constants/positive_infinity.d.ts +29 -0
- package/esm/constants/positive_infinity.d.ts.map +1 -0
- package/esm/constants/positive_infinity.js +13 -0
- package/esm/constants/positive_infinity.js.map +1 -0
- package/esm/constants/positive_zero.d.ts +38 -0
- package/esm/constants/positive_zero.d.ts.map +1 -0
- package/esm/constants/positive_zero.js +33 -0
- package/esm/constants/positive_zero.js.map +1 -0
- package/esm/constants/sqrt1_2.d.ts +9 -0
- package/esm/constants/sqrt1_2.d.ts.map +1 -0
- package/esm/constants/sqrt1_2.js +8 -0
- package/esm/constants/sqrt1_2.js.map +1 -0
- package/esm/constants/sqrt2.d.ts +9 -0
- package/esm/constants/sqrt2.d.ts.map +1 -0
- package/esm/constants/sqrt2.js +8 -0
- package/esm/constants/sqrt2.js.map +1 -0
- package/esm/cos.d.ts +10 -0
- package/esm/cos.d.ts.map +1 -0
- package/esm/cos.js +29 -0
- package/esm/cos.js.map +1 -0
- package/esm/cosh.d.ts +10 -0
- package/esm/cosh.d.ts.map +1 -0
- package/esm/cosh.js +18 -0
- package/esm/cosh.js.map +1 -0
- package/esm/exp.d.ts +20 -0
- package/esm/exp.d.ts.map +1 -0
- package/esm/exp.js +45 -0
- package/esm/exp.js.map +1 -0
- package/esm/expm1.d.ts +11 -0
- package/esm/expm1.d.ts.map +1 -0
- package/esm/expm1.js +35 -0
- package/esm/expm1.js.map +1 -0
- package/esm/f16round.d.ts +24 -0
- package/esm/f16round.d.ts.map +1 -0
- package/esm/f16round.js +39 -0
- package/esm/f16round.js.map +1 -0
- package/esm/float16/constants.d.ts +97 -0
- package/esm/float16/constants.d.ts.map +1 -0
- package/esm/float16/constants.js +96 -0
- package/esm/float16/constants.js.map +1 -0
- package/esm/float16/decode.d.ts +40 -0
- package/esm/float16/decode.d.ts.map +1 -0
- package/esm/float16/decode.js +61 -0
- package/esm/float16/decode.js.map +1 -0
- package/esm/float16/encode.d.ts +67 -0
- package/esm/float16/encode.d.ts.map +1 -0
- package/esm/float16/encode.js +71 -0
- package/esm/float16/encode.js.map +1 -0
- package/esm/float16/guards.d.ts +22 -0
- package/esm/float16/guards.d.ts.map +1 -0
- package/esm/float16/guards.js +12 -0
- package/esm/float16/guards.js.map +1 -0
- package/esm/float16/index.d.ts +11 -0
- package/esm/float16/index.d.ts.map +1 -0
- package/esm/float16/index.js +11 -0
- package/esm/float16/index.js.map +1 -0
- package/esm/float16/round.d.ts +25 -0
- package/esm/float16/round.d.ts.map +1 -0
- package/esm/float16/round.js +43 -0
- package/esm/float16/round.js.map +1 -0
- package/esm/float32/constants.d.ts +96 -0
- package/esm/float32/constants.d.ts.map +1 -0
- package/esm/float32/constants.js +95 -0
- package/esm/float32/constants.js.map +1 -0
- package/esm/float32/decode.d.ts +38 -0
- package/esm/float32/decode.d.ts.map +1 -0
- package/esm/float32/decode.js +64 -0
- package/esm/float32/decode.js.map +1 -0
- package/esm/float32/encode.d.ts +50 -0
- package/esm/float32/encode.d.ts.map +1 -0
- package/esm/float32/encode.js +71 -0
- package/esm/float32/encode.js.map +1 -0
- package/esm/float32/guards.d.ts +37 -0
- package/esm/float32/guards.d.ts.map +1 -0
- package/esm/float32/guards.js +16 -0
- package/esm/float32/guards.js.map +1 -0
- package/esm/float32/index.d.ts +11 -0
- package/esm/float32/index.d.ts.map +1 -0
- package/esm/float32/index.js +11 -0
- package/esm/float32/index.js.map +1 -0
- package/esm/float32/round.d.ts +23 -0
- package/esm/float32/round.d.ts.map +1 -0
- package/esm/float32/round.js +33 -0
- package/esm/float32/round.js.map +1 -0
- package/esm/floor.d.ts +10 -0
- package/esm/floor.d.ts.map +1 -0
- package/esm/floor.js +29 -0
- package/esm/floor.js.map +1 -0
- package/esm/fround.d.ts +23 -0
- package/esm/fround.d.ts.map +1 -0
- package/esm/fround.js +32 -0
- package/esm/fround.js.map +1 -0
- package/esm/guards/finite.d.ts +23 -0
- package/esm/guards/finite.d.ts.map +1 -0
- package/esm/guards/finite.js +18 -0
- package/esm/guards/finite.js.map +1 -0
- package/esm/guards/index.d.ts +50 -0
- package/esm/guards/index.d.ts.map +1 -0
- package/esm/guards/index.js +50 -0
- package/esm/guards/index.js.map +1 -0
- package/esm/guards/infinity.d.ts +3 -0
- package/esm/guards/infinity.d.ts.map +1 -0
- package/esm/guards/infinity.js +3 -0
- package/esm/guards/infinity.js.map +1 -0
- package/esm/guards/integer.d.ts +47 -0
- package/esm/guards/integer.d.ts.map +1 -0
- package/esm/guards/integer.js +19 -0
- package/esm/guards/integer.js.map +1 -0
- package/esm/guards/nan.d.ts +61 -0
- package/esm/guards/nan.d.ts.map +1 -0
- package/esm/guards/nan.js +63 -0
- package/esm/guards/nan.js.map +1 -0
- package/esm/guards/negative_infinity.d.ts +19 -0
- package/esm/guards/negative_infinity.d.ts.map +1 -0
- package/esm/guards/negative_infinity.js +21 -0
- package/esm/guards/negative_infinity.js.map +1 -0
- package/esm/guards/negative_zero.d.ts +12 -0
- package/esm/guards/negative_zero.d.ts.map +1 -0
- package/esm/guards/negative_zero.js +20 -0
- package/esm/guards/negative_zero.js.map +1 -0
- package/esm/guards/positive_infinity.d.ts +19 -0
- package/esm/guards/positive_infinity.d.ts.map +1 -0
- package/esm/guards/positive_infinity.js +21 -0
- package/esm/guards/positive_infinity.js.map +1 -0
- package/esm/guards/positive_zero.d.ts +17 -0
- package/esm/guards/positive_zero.d.ts.map +1 -0
- package/esm/guards/positive_zero.js +19 -0
- package/esm/guards/positive_zero.js.map +1 -0
- package/esm/guards/safe_integer.d.ts +33 -0
- package/esm/guards/safe_integer.d.ts.map +1 -0
- package/esm/guards/safe_integer.js +22 -0
- package/esm/guards/safe_integer.js.map +1 -0
- package/esm/hypot.d.ts +18 -0
- package/esm/hypot.d.ts.map +1 -0
- package/esm/hypot.js +60 -0
- package/esm/hypot.js.map +1 -0
- package/esm/ieee754.d.ts +16 -0
- package/esm/ieee754.d.ts.map +1 -0
- package/esm/ieee754.js +16 -0
- package/esm/ieee754.js.map +1 -0
- package/esm/imul.d.ts +17 -0
- package/esm/imul.d.ts.map +1 -0
- package/esm/imul.js +21 -0
- package/esm/imul.js.map +1 -0
- package/esm/index.d.ts +84 -0
- package/esm/index.d.ts.map +1 -0
- package/esm/index.js +84 -0
- package/esm/index.js.map +1 -0
- package/esm/internal/ieee754.d.ts +174 -0
- package/esm/internal/ieee754.d.ts.map +1 -0
- package/esm/internal/ieee754.js +194 -0
- package/esm/internal/ieee754.js.map +1 -0
- package/esm/internal/primordials.d.ts +30 -0
- package/esm/internal/primordials.d.ts.map +1 -0
- package/esm/internal/primordials.js +27 -0
- package/esm/internal/primordials.js.map +1 -0
- package/esm/log.d.ts +9 -0
- package/esm/log.d.ts.map +1 -0
- package/esm/log.js +43 -0
- package/esm/log.js.map +1 -0
- package/esm/log10.d.ts +9 -0
- package/esm/log10.d.ts.map +1 -0
- package/esm/log10.js +18 -0
- package/esm/log10.js.map +1 -0
- package/esm/log1p.d.ts +10 -0
- package/esm/log1p.d.ts.map +1 -0
- package/esm/log1p.js +29 -0
- package/esm/log1p.js.map +1 -0
- package/esm/log2.d.ts +12 -0
- package/esm/log2.d.ts.map +1 -0
- package/esm/log2.js +21 -0
- package/esm/log2.js.map +1 -0
- package/esm/max.d.ts +22 -0
- package/esm/max.d.ts.map +1 -0
- package/esm/max.js +48 -0
- package/esm/max.js.map +1 -0
- package/esm/min.d.ts +10 -0
- package/esm/min.d.ts.map +1 -0
- package/esm/min.js +33 -0
- package/esm/min.js.map +1 -0
- package/esm/package.json +3 -0
- package/esm/pow.d.ts +31 -0
- package/esm/pow.d.ts.map +1 -0
- package/esm/pow.js +33 -0
- package/esm/pow.js.map +1 -0
- package/esm/random.d.ts +93 -0
- package/esm/random.d.ts.map +1 -0
- package/esm/random.js +237 -0
- package/esm/random.js.map +1 -0
- package/esm/round.d.ts +9 -0
- package/esm/round.d.ts.map +1 -0
- package/esm/round.js +21 -0
- package/esm/round.js.map +1 -0
- package/esm/sign.d.ts +17 -0
- package/esm/sign.d.ts.map +1 -0
- package/esm/sign.js +19 -0
- package/esm/sign.js.map +1 -0
- package/esm/sin.d.ts +14 -0
- package/esm/sin.d.ts.map +1 -0
- package/esm/sin.js +28 -0
- package/esm/sin.js.map +1 -0
- package/esm/sinh.d.ts +14 -0
- package/esm/sinh.d.ts.map +1 -0
- package/esm/sinh.js +19 -0
- package/esm/sinh.js.map +1 -0
- package/esm/sqrt.d.ts +19 -0
- package/esm/sqrt.d.ts.map +1 -0
- package/esm/sqrt.js +42 -0
- package/esm/sqrt.js.map +1 -0
- package/esm/tan.d.ts +9 -0
- package/esm/tan.d.ts.map +1 -0
- package/esm/tan.js +23 -0
- package/esm/tan.js.map +1 -0
- package/esm/tanh.d.ts +17 -0
- package/esm/tanh.d.ts.map +1 -0
- package/esm/tanh.js +31 -0
- package/esm/tanh.js.map +1 -0
- package/esm/trunc.d.ts +21 -0
- package/esm/trunc.d.ts.map +1 -0
- package/esm/trunc.js +47 -0
- package/esm/trunc.js.map +1 -0
- package/esm/types/finite.d.ts +16 -0
- package/esm/types/finite.d.ts.map +1 -0
- package/esm/types/finite.js +3 -0
- package/esm/types/finite.js.map +1 -0
- package/esm/types/float.d.ts +65 -0
- package/esm/types/float.d.ts.map +1 -0
- package/esm/types/float.js +3 -0
- package/esm/types/float.js.map +1 -0
- package/esm/types/index.d.ts +6 -0
- package/esm/types/index.d.ts.map +1 -0
- package/esm/types/index.js +6 -0
- package/esm/types/index.js.map +1 -0
- package/esm/types/integer.d.ts +147 -0
- package/esm/types/integer.d.ts.map +1 -0
- package/esm/types/integer.js +4 -0
- package/esm/types/integer.js.map +1 -0
- package/esm/types/precision.d.ts +46 -0
- package/esm/types/precision.d.ts.map +1 -0
- package/esm/types/precision.js +8 -0
- package/esm/types/precision.js.map +1 -0
- package/esm/types/safe_integer.d.ts +17 -0
- package/esm/types/safe_integer.d.ts.map +1 -0
- package/esm/types/safe_integer.js +4 -0
- package/esm/types/safe_integer.js.map +1 -0
- package/package.json +1834 -0
- package/src/abs.ts +18 -0
- package/src/acos.ts +24 -0
- package/src/acosh.ts +28 -0
- package/src/asin.ts +24 -0
- package/src/asinh.ts +21 -0
- package/src/atan.ts +64 -0
- package/src/atan2.ts +58 -0
- package/src/atanh.ts +26 -0
- package/src/cbrt.ts +22 -0
- package/src/ceil.ts +27 -0
- package/src/clamp.ts +29 -0
- package/src/clz32.ts +45 -0
- package/src/constants/e.ts +18 -0
- package/src/constants/epsilon.ts +25 -0
- package/src/constants/index.ts +22 -0
- package/src/constants/infinity.ts +2 -0
- package/src/constants/ln10.ts +9 -0
- package/src/constants/ln2.ts +9 -0
- package/src/constants/log10e.ts +9 -0
- package/src/constants/log2e.ts +9 -0
- package/src/constants/max_safe_integer.ts +10 -0
- package/src/constants/max_value.ts +9 -0
- package/src/constants/min_safe_integer.ts +11 -0
- package/src/constants/min_value.ts +9 -0
- package/src/constants/nan.ts +57 -0
- package/src/constants/negative_infinity.ts +28 -0
- package/src/constants/negative_zero.ts +34 -0
- package/src/constants/pi.ts +9 -0
- package/src/constants/positive_infinity.ts +30 -0
- package/src/constants/positive_zero.ts +41 -0
- package/src/constants/sqrt1_2.ts +8 -0
- package/src/constants/sqrt2.ts +8 -0
- package/src/cos.ts +29 -0
- package/src/cosh.ts +18 -0
- package/src/exp.ts +45 -0
- package/src/expm1.ts +31 -0
- package/src/f16round.ts +39 -0
- package/src/float16/constants.ts +106 -0
- package/src/float16/decode.ts +61 -0
- package/src/float16/encode.ts +72 -0
- package/src/float16/guards.ts +33 -0
- package/src/float16/index.ts +10 -0
- package/src/float16/round.ts +43 -0
- package/src/float32/constants.ts +105 -0
- package/src/float32/decode.ts +64 -0
- package/src/float32/encode.ts +71 -0
- package/src/float32/guards.ts +54 -0
- package/src/float32/index.ts +10 -0
- package/src/float32/round.ts +33 -0
- package/src/floor.ts +26 -0
- package/src/fround.ts +32 -0
- package/src/guards/finite.ts +45 -0
- package/src/guards/index.ts +49 -0
- package/src/guards/infinity.ts +2 -0
- package/src/guards/integer.ts +62 -0
- package/src/guards/nan.ts +65 -0
- package/src/guards/negative_infinity.ts +22 -0
- package/src/guards/negative_zero.ts +21 -0
- package/src/guards/positive_infinity.ts +22 -0
- package/src/guards/positive_zero.ts +19 -0
- package/src/guards/safe_integer.ts +56 -0
- package/src/hypot.ts +59 -0
- package/src/ieee754.ts +15 -0
- package/src/imul.ts +21 -0
- package/src/index.ts +84 -0
- package/src/internal/ieee754.ts +255 -0
- package/src/internal/primordials.ts +33 -0
- package/src/log.ts +42 -0
- package/src/log10.ts +18 -0
- package/src/log1p.ts +26 -0
- package/src/log2.ts +21 -0
- package/src/max.ts +46 -0
- package/src/min.ts +32 -0
- package/src/pow.ts +33 -0
- package/src/random.ts +241 -0
- package/src/round.ts +20 -0
- package/src/sign.ts +19 -0
- package/src/sin.ts +29 -0
- package/src/sinh.ts +19 -0
- package/src/sqrt.ts +40 -0
- package/src/tan.ts +22 -0
- package/src/tanh.ts +28 -0
- package/src/trunc.ts +44 -0
- package/src/types/finite.ts +23 -0
- package/src/types/float.ts +74 -0
- package/src/types/index.ts +5 -0
- package/src/types/integer.ts +167 -0
- package/src/types/precision.ts +51 -0
- package/src/types/safe_integer.ts +18 -0
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared generic implementation for IEEE‑754 binary floating‑point
|
|
3
|
+
* encoding, decoding, and rounding.
|
|
4
|
+
*
|
|
5
|
+
* @module internal/ieee754
|
|
6
|
+
*/
|
|
7
|
+
/** Descriptor for an IEEE‑754 binary floating‑point format. */
|
|
8
|
+
export interface BigIntFloatFormat extends Format {
|
|
9
|
+
/** Controls the output type of the bit pattern. @default {false} */
|
|
10
|
+
bigint: true;
|
|
11
|
+
}
|
|
12
|
+
/** Descriptor for an IEEE‑754 binary floating‑point format. */
|
|
13
|
+
export interface FloatFormat extends Format {
|
|
14
|
+
/** Optional flag indicating the output type should be a number. */
|
|
15
|
+
bigint?: false | undefined;
|
|
16
|
+
}
|
|
17
|
+
interface Format {
|
|
18
|
+
/** Number of exponent bits (e.g. 8 for binary32). */
|
|
19
|
+
exponent: number;
|
|
20
|
+
/** Number of mantissa bits (e.g. 23 for binary32). */
|
|
21
|
+
mantissa: number;
|
|
22
|
+
/** Exponent bias (e.g. 127 for binary32). */
|
|
23
|
+
bias: number;
|
|
24
|
+
/** Encoded bit‑pattern for NaN. */
|
|
25
|
+
nan: number | bigint;
|
|
26
|
+
/** Encoded bit‑pattern for +∞. */
|
|
27
|
+
positive_infinity: number | bigint;
|
|
28
|
+
/** Encoded bit‑pattern for –∞. */
|
|
29
|
+
negative_infinity: number | bigint;
|
|
30
|
+
/** Encoded bit‑pattern for –0. */
|
|
31
|
+
negative_zero: number | bigint;
|
|
32
|
+
/** Encoded bit‑pattern for +0. */
|
|
33
|
+
positive_zero: number | bigint;
|
|
34
|
+
/** Optional flag indicating whether the output should be a bigint. */
|
|
35
|
+
bigint?: boolean | undefined;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Encode a JS number into an IEEE‑754 bit pattern (as a BigInt).
|
|
39
|
+
*
|
|
40
|
+
* @param value The number to encode.
|
|
41
|
+
* @param fmt Describes exponent/mantissa sizes, bias, and specials.
|
|
42
|
+
* @returns The raw bits (as BigInt).
|
|
43
|
+
* @internal
|
|
44
|
+
*/
|
|
45
|
+
export declare function encode(value: number, fmt: BigIntFloatFormat): bigint;
|
|
46
|
+
export declare function encode(value: number, fmt: FloatFormat): number;
|
|
47
|
+
/**
|
|
48
|
+
* Decode an IEEE‑754 bit pattern back into a JavaScript number.
|
|
49
|
+
*
|
|
50
|
+
* @param bits The raw bits (BigInt or number).
|
|
51
|
+
* @param fmt Describes exponent/mantissa sizes, bias, and specials.
|
|
52
|
+
* @returns The decoded JS number.
|
|
53
|
+
* @internal
|
|
54
|
+
*/
|
|
55
|
+
export declare function decode(bits: string | bigint | number, fmt: FloatFormat): number;
|
|
56
|
+
/**
|
|
57
|
+
* Round a JS number to the nearest representable value in the given format.
|
|
58
|
+
*
|
|
59
|
+
* @param value The number to round.
|
|
60
|
+
* @param fmt Describes exponent/mantissa sizes, bias, and specials.
|
|
61
|
+
* @returns The rounded JS number.
|
|
62
|
+
* @internal
|
|
63
|
+
*/
|
|
64
|
+
export declare function fround(value: number, fmt?: FloatFormat): number;
|
|
65
|
+
/**
|
|
66
|
+
* Represents the IEEE-754 binary16 (half-precision) floating-point format.
|
|
67
|
+
*
|
|
68
|
+
* @internal
|
|
69
|
+
*/
|
|
70
|
+
export declare const float16: {
|
|
71
|
+
readonly exponent: 5;
|
|
72
|
+
readonly mantissa: 10;
|
|
73
|
+
readonly bias: 15;
|
|
74
|
+
readonly nan: 32256n;
|
|
75
|
+
readonly positive_infinity: 31744n;
|
|
76
|
+
readonly negative_infinity: 64512n;
|
|
77
|
+
readonly negative_zero: 32768n;
|
|
78
|
+
readonly positive_zero: 0n;
|
|
79
|
+
};
|
|
80
|
+
/**
|
|
81
|
+
* Represents the IEEE-754 binary32 (single-precision) floating-point format.
|
|
82
|
+
*
|
|
83
|
+
* @internal
|
|
84
|
+
*/
|
|
85
|
+
export declare const float32: {
|
|
86
|
+
readonly exponent: 8;
|
|
87
|
+
readonly mantissa: 23;
|
|
88
|
+
readonly bias: 127;
|
|
89
|
+
readonly nan: 2143289344n;
|
|
90
|
+
readonly positive_infinity: 2139095040n;
|
|
91
|
+
readonly negative_infinity: 4286578688n;
|
|
92
|
+
readonly negative_zero: 2147483648n;
|
|
93
|
+
readonly positive_zero: 0n;
|
|
94
|
+
};
|
|
95
|
+
/**
|
|
96
|
+
* Represents the IEEE-754 binary64 (double-precision) floating-point format.
|
|
97
|
+
*
|
|
98
|
+
* @internal
|
|
99
|
+
*/
|
|
100
|
+
export declare const float64: {
|
|
101
|
+
readonly exponent: 11;
|
|
102
|
+
readonly mantissa: 52;
|
|
103
|
+
readonly bias: 1023;
|
|
104
|
+
readonly nan: 9221120237041090560n;
|
|
105
|
+
readonly positive_infinity: 9218868437227405312n;
|
|
106
|
+
readonly negative_infinity: 18442240474082181120n;
|
|
107
|
+
readonly negative_zero: 9223372036854775808n;
|
|
108
|
+
readonly positive_zero: 0n;
|
|
109
|
+
};
|
|
110
|
+
/**
|
|
111
|
+
* Represents the IEEE-754 binary128 (quadruple-precision) floating-point
|
|
112
|
+
* format.
|
|
113
|
+
*
|
|
114
|
+
* @internal
|
|
115
|
+
*/
|
|
116
|
+
export declare const float128: {
|
|
117
|
+
readonly exponent: 15;
|
|
118
|
+
readonly mantissa: 112;
|
|
119
|
+
readonly bias: 16383;
|
|
120
|
+
readonly nan: 170138587312039964317873038467719495680n;
|
|
121
|
+
readonly positive_infinity: 170135991163610696904058773219554885632n;
|
|
122
|
+
readonly negative_infinity: 340277174624079928635746076935438991360n;
|
|
123
|
+
readonly negative_zero: 170141183460469231731687303715884105728n;
|
|
124
|
+
readonly positive_zero: 0n;
|
|
125
|
+
};
|
|
126
|
+
/**
|
|
127
|
+
* Represents all supported IEEE-754 floating-point formats.
|
|
128
|
+
*
|
|
129
|
+
* @internal
|
|
130
|
+
*/
|
|
131
|
+
export declare const formats: {
|
|
132
|
+
readonly float16: {
|
|
133
|
+
readonly exponent: 5;
|
|
134
|
+
readonly mantissa: 10;
|
|
135
|
+
readonly bias: 15;
|
|
136
|
+
readonly nan: 32256n;
|
|
137
|
+
readonly positive_infinity: 31744n;
|
|
138
|
+
readonly negative_infinity: 64512n;
|
|
139
|
+
readonly negative_zero: 32768n;
|
|
140
|
+
readonly positive_zero: 0n;
|
|
141
|
+
};
|
|
142
|
+
readonly float32: {
|
|
143
|
+
readonly exponent: 8;
|
|
144
|
+
readonly mantissa: 23;
|
|
145
|
+
readonly bias: 127;
|
|
146
|
+
readonly nan: 2143289344n;
|
|
147
|
+
readonly positive_infinity: 2139095040n;
|
|
148
|
+
readonly negative_infinity: 4286578688n;
|
|
149
|
+
readonly negative_zero: 2147483648n;
|
|
150
|
+
readonly positive_zero: 0n;
|
|
151
|
+
};
|
|
152
|
+
readonly float64: {
|
|
153
|
+
readonly exponent: 11;
|
|
154
|
+
readonly mantissa: 52;
|
|
155
|
+
readonly bias: 1023;
|
|
156
|
+
readonly nan: 9221120237041090560n;
|
|
157
|
+
readonly positive_infinity: 9218868437227405312n;
|
|
158
|
+
readonly negative_infinity: 18442240474082181120n;
|
|
159
|
+
readonly negative_zero: 9223372036854775808n;
|
|
160
|
+
readonly positive_zero: 0n;
|
|
161
|
+
};
|
|
162
|
+
readonly float128: {
|
|
163
|
+
readonly exponent: 15;
|
|
164
|
+
readonly mantissa: 112;
|
|
165
|
+
readonly bias: 16383;
|
|
166
|
+
readonly nan: 170138587312039964317873038467719495680n;
|
|
167
|
+
readonly positive_infinity: 170135991163610696904058773219554885632n;
|
|
168
|
+
readonly negative_infinity: 340277174624079928635746076935438991360n;
|
|
169
|
+
readonly negative_zero: 170141183460469231731687303715884105728n;
|
|
170
|
+
readonly positive_zero: 0n;
|
|
171
|
+
};
|
|
172
|
+
};
|
|
173
|
+
export {};
|
|
174
|
+
//# sourceMappingURL=ieee754.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ieee754.d.ts","sourceRoot":"","sources":["../../src/internal/ieee754.ts"],"names":[],"mappings":"AACA;;;;;GAKG;AAoBH,+DAA+D;AAC/D,MAAM,WAAW,iBAAkB,SAAQ,MAAM;IAC/C,oEAAoE;IACpE,MAAM,EAAE,IAAI,CAAC;CACd;AAED,+DAA+D;AAC/D,MAAM,WAAW,WAAY,SAAQ,MAAM;IACzC,mEAAmE;IACnE,MAAM,CAAC,EAAE,KAAK,GAAG,SAAS,CAAC;CAC5B;AAED,UAAU,MAAM;IACd,qDAAqD;IACrD,QAAQ,EAAE,MAAM,CAAC;IACjB,sDAAsD;IACtD,QAAQ,EAAE,MAAM,CAAC;IACjB,6CAA6C;IAC7C,IAAI,EAAE,MAAM,CAAC;IACb,mCAAmC;IACnC,GAAG,EAAE,MAAM,GAAG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, and rounding.
|
|
5
|
+
*
|
|
6
|
+
* @module internal/ieee754
|
|
7
|
+
*/
|
|
8
|
+
import { isPositiveInfinity, POSITIVE_INFINITY, } from "../guards/positive_infinity.js";
|
|
9
|
+
import { isNegativeInfinity, NEGATIVE_INFINITY, } from "../guards/negative_infinity.js";
|
|
10
|
+
import { isNaN, NAN } from "../guards/nan.js";
|
|
11
|
+
import { isNegativeZero, NEGATIVE_ZERO } from "../guards/negative_zero.js";
|
|
12
|
+
import { isPositiveZero, POSITIVE_ZERO } from "../guards/positive_zero.js";
|
|
13
|
+
import { abs } from "../abs.js";
|
|
14
|
+
import { floor } from "../floor.js";
|
|
15
|
+
import { log2 } from "../log2.js";
|
|
16
|
+
import { pow } from "../pow.js";
|
|
17
|
+
import { round } from "../round.js";
|
|
18
|
+
import { BigInt, Number } from "./primordials.js";
|
|
19
|
+
export function encode(value, fmt) {
|
|
20
|
+
return (fmt.bigint ? BigInt : Number)(inner_encode(value, fmt));
|
|
21
|
+
}
|
|
22
|
+
function inner_encode(value, fmt) {
|
|
23
|
+
if (isNaN(value))
|
|
24
|
+
return fmt.nan;
|
|
25
|
+
if (isPositiveInfinity(value))
|
|
26
|
+
return fmt.positive_infinity;
|
|
27
|
+
if (isNegativeInfinity(value))
|
|
28
|
+
return fmt.negative_infinity;
|
|
29
|
+
if (isNegativeZero(value))
|
|
30
|
+
return fmt.negative_zero;
|
|
31
|
+
if (isPositiveZero(value))
|
|
32
|
+
return fmt.positive_zero;
|
|
33
|
+
const normal = 1 - fmt.bias;
|
|
34
|
+
// subnormal threshold = 2^(1-bias)
|
|
35
|
+
const cutoff = pow(2, normal);
|
|
36
|
+
const sign = BigInt(value < 0 ? 1 : 0);
|
|
37
|
+
const shift = BigInt(fmt.exponent + fmt.mantissa);
|
|
38
|
+
const absolute = abs(value);
|
|
39
|
+
if (absolute < cutoff) {
|
|
40
|
+
// subnormal
|
|
41
|
+
const scale = normal - fmt.mantissa;
|
|
42
|
+
const mant = BigInt(round(absolute / pow(2, scale)));
|
|
43
|
+
return (sign << shift) | mant;
|
|
44
|
+
}
|
|
45
|
+
// normal
|
|
46
|
+
let expo = floor(log2(absolute)), mant = absolute / pow(2, expo);
|
|
47
|
+
if (mant < 1) {
|
|
48
|
+
mant *= 2;
|
|
49
|
+
expo--;
|
|
50
|
+
}
|
|
51
|
+
else if (mant >= 2) {
|
|
52
|
+
mant /= 2;
|
|
53
|
+
expo++;
|
|
54
|
+
}
|
|
55
|
+
const mant_scale = pow(2, fmt.mantissa);
|
|
56
|
+
let mant_bits = round((mant - 1) * mant_scale);
|
|
57
|
+
if (mant_bits === mant_scale) {
|
|
58
|
+
mant_bits = 0;
|
|
59
|
+
expo++;
|
|
60
|
+
}
|
|
61
|
+
const biased = expo + fmt.bias;
|
|
62
|
+
if (biased >= (1 << fmt.exponent) - 1) {
|
|
63
|
+
return value < 0 ? fmt.negative_infinity : fmt.positive_infinity;
|
|
64
|
+
}
|
|
65
|
+
const e = BigInt(biased);
|
|
66
|
+
const m = BigInt(mant_bits);
|
|
67
|
+
return (sign << shift) | (e << BigInt(fmt.mantissa)) | m;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Decode an IEEE‑754 bit pattern back into a JavaScript number.
|
|
71
|
+
*
|
|
72
|
+
* @param bits The raw bits (BigInt or number).
|
|
73
|
+
* @param fmt Describes exponent/mantissa sizes, bias, and specials.
|
|
74
|
+
* @returns The decoded JS number.
|
|
75
|
+
* @internal
|
|
76
|
+
*/
|
|
77
|
+
export function decode(bits, fmt) {
|
|
78
|
+
const b = BigInt(bits);
|
|
79
|
+
if (b === BigInt(fmt.nan))
|
|
80
|
+
return NAN;
|
|
81
|
+
if (b === BigInt(fmt.positive_infinity))
|
|
82
|
+
return POSITIVE_INFINITY;
|
|
83
|
+
if (b === BigInt(fmt.negative_infinity))
|
|
84
|
+
return NEGATIVE_INFINITY;
|
|
85
|
+
if (b === BigInt(fmt.negative_zero))
|
|
86
|
+
return NEGATIVE_ZERO;
|
|
87
|
+
if (b === BigInt(fmt.positive_zero))
|
|
88
|
+
return POSITIVE_ZERO;
|
|
89
|
+
const shift = fmt.exponent + fmt.mantissa;
|
|
90
|
+
const m = BigInt(fmt.mantissa), e = BigInt(fmt.exponent);
|
|
91
|
+
const mask_m = (1n << m) - 1n;
|
|
92
|
+
const mask_e = ((1n << e) - 1n) << m;
|
|
93
|
+
const sign = ((b >> BigInt(shift)) & 1n) === 1n ? -1 : 1;
|
|
94
|
+
const expo = (b & mask_e) >> m, mant = b & mask_m;
|
|
95
|
+
if (expo === 0n) {
|
|
96
|
+
// subnormal
|
|
97
|
+
const subx = 1 - fmt.bias;
|
|
98
|
+
return sign * Number(mant) * pow(2, subx - fmt.mantissa);
|
|
99
|
+
}
|
|
100
|
+
else if (expo === (1n << e) - 1n) {
|
|
101
|
+
if (mant)
|
|
102
|
+
return NAN;
|
|
103
|
+
if (sign > 0)
|
|
104
|
+
return POSITIVE_INFINITY;
|
|
105
|
+
return NEGATIVE_INFINITY;
|
|
106
|
+
}
|
|
107
|
+
const exp = Number(expo) - fmt.bias;
|
|
108
|
+
return sign * (1 + Number(mant) / pow(2, fmt.mantissa)) * pow(2, exp);
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Round a JS number to the nearest representable value in the given format.
|
|
112
|
+
*
|
|
113
|
+
* @param value The number to round.
|
|
114
|
+
* @param fmt Describes exponent/mantissa sizes, bias, and specials.
|
|
115
|
+
* @returns The rounded JS number.
|
|
116
|
+
* @internal
|
|
117
|
+
*/
|
|
118
|
+
export function fround(value, fmt) {
|
|
119
|
+
fmt ?? (fmt = float32);
|
|
120
|
+
return decode(encode(value, fmt), fmt);
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Represents the IEEE-754 binary16 (half-precision) floating-point format.
|
|
124
|
+
*
|
|
125
|
+
* @internal
|
|
126
|
+
*/
|
|
127
|
+
export const float16 = {
|
|
128
|
+
exponent: 5,
|
|
129
|
+
mantissa: 10,
|
|
130
|
+
bias: 15,
|
|
131
|
+
nan: 0x7e00n,
|
|
132
|
+
positive_infinity: 0x7c00n,
|
|
133
|
+
negative_infinity: 0xfc00n,
|
|
134
|
+
negative_zero: 0x8000n,
|
|
135
|
+
positive_zero: 0n,
|
|
136
|
+
};
|
|
137
|
+
/**
|
|
138
|
+
* Represents the IEEE-754 binary32 (single-precision) floating-point format.
|
|
139
|
+
*
|
|
140
|
+
* @internal
|
|
141
|
+
*/
|
|
142
|
+
export const float32 = {
|
|
143
|
+
exponent: 8,
|
|
144
|
+
mantissa: 23,
|
|
145
|
+
bias: 127,
|
|
146
|
+
nan: 0x7fc00000n,
|
|
147
|
+
positive_infinity: 0x7f800000n,
|
|
148
|
+
negative_infinity: 0xff800000n,
|
|
149
|
+
negative_zero: 0x80000000n,
|
|
150
|
+
positive_zero: 0n,
|
|
151
|
+
};
|
|
152
|
+
/**
|
|
153
|
+
* Represents the IEEE-754 binary64 (double-precision) floating-point format.
|
|
154
|
+
*
|
|
155
|
+
* @internal
|
|
156
|
+
*/
|
|
157
|
+
export const float64 = {
|
|
158
|
+
exponent: 11,
|
|
159
|
+
mantissa: 52,
|
|
160
|
+
bias: 1023,
|
|
161
|
+
nan: 0x7ff8000000000000n,
|
|
162
|
+
positive_infinity: 0x7ff0000000000000n,
|
|
163
|
+
negative_infinity: 0xfff0000000000000n,
|
|
164
|
+
negative_zero: 0x8000000000000000n,
|
|
165
|
+
positive_zero: 0n,
|
|
166
|
+
};
|
|
167
|
+
/**
|
|
168
|
+
* Represents the IEEE-754 binary128 (quadruple-precision) floating-point
|
|
169
|
+
* format.
|
|
170
|
+
*
|
|
171
|
+
* @internal
|
|
172
|
+
*/
|
|
173
|
+
export const float128 = {
|
|
174
|
+
exponent: 15,
|
|
175
|
+
mantissa: 112,
|
|
176
|
+
bias: 16383,
|
|
177
|
+
nan: 0x7fff8000000000000000000000000000n,
|
|
178
|
+
positive_infinity: 0x7fff0000000000000000000000000000n,
|
|
179
|
+
negative_infinity: 0xffff0000000000000000000000000000n,
|
|
180
|
+
negative_zero: 0x80000000000000000000000000000000n,
|
|
181
|
+
positive_zero: 0n,
|
|
182
|
+
};
|
|
183
|
+
/**
|
|
184
|
+
* Represents all supported IEEE-754 floating-point formats.
|
|
185
|
+
*
|
|
186
|
+
* @internal
|
|
187
|
+
*/
|
|
188
|
+
export const formats = {
|
|
189
|
+
float16,
|
|
190
|
+
float32,
|
|
191
|
+
float64,
|
|
192
|
+
float128,
|
|
193
|
+
};
|
|
194
|
+
//# sourceMappingURL=ieee754.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ieee754.js","sourceRoot":"","sources":["../../src/internal/ieee754.ts"],"names":[],"mappings":"AAAA,0BAA0B;AAC1B;;;;;GAKG;AAEH,OAAO,EACL,kBAAkB,EAClB,iBAAiB,GAClB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EACL,kBAAkB,EAClB,iBAAiB,GAClB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3E,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3E,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAChC,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAClC,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAChC,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AA6ClD,MAAM,UAAU,MAAM,CACpB,KAAa,EACb,GAAoC;IAEpC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CA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AAiB,EAAE,WAAW;IAC9B,iBAAiB,EAAE,WAAW;IAC9B,aAAa,EAAE,WAAW;IAC1B,aAAa,EAAE,EAAE;CACa,CAAC;AAEjC;;;;GAIG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG;IACrB,QAAQ,EAAE,EAAE;IACZ,QAAQ,EAAE,EAAE;IACZ,IAAI,EAAE,IAAI;IACV,GAAG,EAAE,mBAAmB;IACxB,iBAAiB,EAAE,mBAAmB;IACtC,iBAAiB,EAAE,mBAAmB;IACtC,aAAa,EAAE,mBAAmB;IAClC,aAAa,EAAE,EAAE;CACa,CAAC;AAEjC;;;;;GAKG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG;IACtB,QAAQ,EAAE,EAAE;IACZ,QAAQ,EAAE,GAAG;IACb,IAAI,EAAE,KAAK;IACX,GAAG,EAAE,mCAAmC;IACxC,iBAAiB,EAAE,mCAAmC;IACtD,iBAAiB,EAAE,mCAAmC;IACtD,aAAa,EAAE,mCAAmC;IAClD,aAAa,EAAE,EAAE;CACa,CAAC;AAEjC;;;;GAIG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG;IACrB,OAAO;IACP,OAAO;IACP,OAAO;IACP,QAAQ;CACsC,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export declare const Date: DateConstructor;
|
|
2
|
+
export declare const DateNow: () => number;
|
|
3
|
+
export declare const DateUTC: {
|
|
4
|
+
(year: number, monthIndex: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): number;
|
|
5
|
+
(year: number, monthIndex?: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): number;
|
|
6
|
+
};
|
|
7
|
+
export declare const DateParse: (s: string) => number;
|
|
8
|
+
export declare const DatePrototype: Date;
|
|
9
|
+
export declare const String: StringConstructor;
|
|
10
|
+
export declare const StringPrototype: String;
|
|
11
|
+
export declare const Number: NumberConstructor;
|
|
12
|
+
export declare const NumberPrototype: Number;
|
|
13
|
+
export declare const BigInt: BigIntConstructor;
|
|
14
|
+
export declare const BigIntAsIntN: (bits: number, int: bigint) => bigint;
|
|
15
|
+
export declare const BigIntAsUintN: (bits: number, int: bigint) => bigint;
|
|
16
|
+
export declare const BigIntPrototype: BigInt;
|
|
17
|
+
export declare const Object: ObjectConstructor;
|
|
18
|
+
export declare const ObjectPrototype: Object;
|
|
19
|
+
export declare const Array: ArrayConstructor;
|
|
20
|
+
export declare const ArrayFrom: typeof Array.from;
|
|
21
|
+
export declare const ArrayPrototype: any[];
|
|
22
|
+
export declare const Function: FunctionConstructor;
|
|
23
|
+
export declare const FunctionPrototype: Function;
|
|
24
|
+
export declare const Symbol: SymbolConstructor;
|
|
25
|
+
export declare const SymbolPrototype: typeof Symbol.prototype;
|
|
26
|
+
export declare const SymbolFor: typeof Symbol.for;
|
|
27
|
+
export declare const SymbolIterator: typeof Symbol.iterator;
|
|
28
|
+
export declare const SymbolToStringTag: typeof Symbol.toStringTag;
|
|
29
|
+
export declare const SymbolToPrimitive: typeof Symbol.toPrimitive;
|
|
30
|
+
//# sourceMappingURL=primordials.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"primordials.d.ts","sourceRoot":"","sources":["../../src/internal/primordials.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,IAAI,EAAE,eAAiC,CAAC;AACrD,eAAO,MAAM,OAAO,cAAW,CAAC;AAChC,eAAO,MAAM,OAAO;;;CAAW,CAAC;AAChC,eAAO,MAAM,SAAS,uBAAa,CAAC;AACpC,eAAO,MAAM,aAAa,MAAiB,CAAC;AAE5C,eAAO,MAAM,MAAM,EAAE,iBAAqC,CAAC;AAC3D,eAAO,MAAM,eAAe,QAAmB,CAAC;AAEhD,eAAO,MAAM,MAAM,EAAE,iBAAqC,CAAC;AAC3D,eAAO,MAAM,eAAe,QAAmB,CAAC;AAEhD,eAAO,MAAM,MAAM,EAAE,iBAAqC,CAAC;AAC3D,eAAO,MAAM,YAAY,uCAA6B,CAAC;AACvD,eAAO,MAAM,aAAa,uCAA8B,CAAC;AACzD,eAAO,MAAM,eAAe,QAAmB,CAAC;AAEhD,eAAO,MAAM,MAAM,EAAE,iBAAqC,CAAC;AAC3D,eAAO,MAAM,eAAe,QAAmB,CAAC;AAEhD,eAAO,MAAM,KAAK,EAAE,gBAAmC,CAAC;AACxD,eAAO,MAAM,SAAS,EAAE,OAAO,KAAK,CAAC,IAA6B,CAAC;AACnE,eAAO,MAAM,cAAc,OAAkB,CAAC;AAE9C,eAAO,MAAM,QAAQ,EAAE,mBAAyC,CAAC;AACjE,eAAO,MAAM,iBAAiB,UAAqB,CAAC;AAEpD,eAAO,MAAM,MAAM,EAAE,iBAAqC,CAAC;AAC3D,eAAO,MAAM,eAAe,EAAE,OAAO,MAAM,CAAC,SAA4B,CAAC;AACzE,eAAO,MAAM,SAAS,EAAE,OAAO,MAAM,CAAC,GAAgB,CAAC;AACvD,eAAO,MAAM,cAAc,EAAE,OAAO,MAAM,CAAC,QAA0B,CAAC;AACtE,eAAO,MAAM,iBAAiB,EAAE,OAAO,MAAM,CAAC,WAAgC,CAAC;AAC/E,eAAO,MAAM,iBAAiB,EAAE,OAAO,MAAM,CAAC,WAAgC,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export const Date = globalThis.Date;
|
|
2
|
+
export const DateNow = Date.now;
|
|
3
|
+
export const DateUTC = Date.UTC;
|
|
4
|
+
export const DateParse = Date.parse;
|
|
5
|
+
export const DatePrototype = Date.prototype;
|
|
6
|
+
export const String = globalThis.String;
|
|
7
|
+
export const StringPrototype = String.prototype;
|
|
8
|
+
export const Number = globalThis.Number;
|
|
9
|
+
export const NumberPrototype = Number.prototype;
|
|
10
|
+
export const BigInt = globalThis.BigInt;
|
|
11
|
+
export const BigIntAsIntN = BigInt.asIntN.bind(BigInt);
|
|
12
|
+
export const BigIntAsUintN = BigInt.asUintN.bind(BigInt);
|
|
13
|
+
export const BigIntPrototype = BigInt.prototype;
|
|
14
|
+
export const Object = globalThis.Object;
|
|
15
|
+
export const ObjectPrototype = Object.prototype;
|
|
16
|
+
export const Array = globalThis.Array;
|
|
17
|
+
export const ArrayFrom = Array.from.bind(Array);
|
|
18
|
+
export const ArrayPrototype = Array.prototype;
|
|
19
|
+
export const Function = globalThis.Function;
|
|
20
|
+
export const FunctionPrototype = Function.prototype;
|
|
21
|
+
export const Symbol = globalThis.Symbol;
|
|
22
|
+
export const SymbolPrototype = Symbol.prototype;
|
|
23
|
+
export const SymbolFor = Symbol.for;
|
|
24
|
+
export const SymbolIterator = Symbol.iterator;
|
|
25
|
+
export const SymbolToStringTag = Symbol.toStringTag;
|
|
26
|
+
export const SymbolToPrimitive = Symbol.toPrimitive;
|
|
27
|
+
//# sourceMappingURL=primordials.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"primordials.js","sourceRoot":"","sources":["../../src/internal/primordials.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,IAAI,GAAoB,UAAU,CAAC,IAAI,CAAC;AACrD,MAAM,CAAC,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC;AAChC,MAAM,CAAC,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC;AAChC,MAAM,CAAC,MAAM,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC;AACpC,MAAM,CAAC,MAAM,aAAa,GAAG,IAAI,CAAC,SAAS,CAAC;AAE5C,MAAM,CAAC,MAAM,MAAM,GAAsB,UAAU,CAAC,MAAM,CAAC;AAC3D,MAAM,CAAC,MAAM,eAAe,GAAG,MAAM,CAAC,SAAS,CAAC;AAEhD,MAAM,CAAC,MAAM,MAAM,GAAsB,UAAU,CAAC,MAAM,CAAC;AAC3D,MAAM,CAAC,MAAM,eAAe,GAAG,MAAM,CAAC,SAAS,CAAC;AAEhD,MAAM,CAAC,MAAM,MAAM,GAAsB,UAAU,CAAC,MAAM,CAAC;AAC3D,MAAM,CAAC,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;AACvD,MAAM,CAAC,MAAM,aAAa,GAAG,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;AACzD,MAAM,CAAC,MAAM,eAAe,GAAG,MAAM,CAAC,SAAS,CAAC;AAEhD,MAAM,CAAC,MAAM,MAAM,GAAsB,UAAU,CAAC,MAAM,CAAC;AAC3D,MAAM,CAAC,MAAM,eAAe,GAAG,MAAM,CAAC,SAAS,CAAC;AAEhD,MAAM,CAAC,MAAM,KAAK,GAAqB,UAAU,CAAC,KAAK,CAAC;AACxD,MAAM,CAAC,MAAM,SAAS,GAAsB,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AACnE,MAAM,CAAC,MAAM,cAAc,GAAG,KAAK,CAAC,SAAS,CAAC;AAE9C,MAAM,CAAC,MAAM,QAAQ,GAAwB,UAAU,CAAC,QAAQ,CAAC;AACjE,MAAM,CAAC,MAAM,iBAAiB,GAAG,QAAQ,CAAC,SAAS,CAAC;AAEpD,MAAM,CAAC,MAAM,MAAM,GAAsB,UAAU,CAAC,MAAM,CAAC;AAC3D,MAAM,CAAC,MAAM,eAAe,GAA4B,MAAM,CAAC,SAAS,CAAC;AACzE,MAAM,CAAC,MAAM,SAAS,GAAsB,MAAM,CAAC,GAAG,CAAC;AACvD,MAAM,CAAC,MAAM,cAAc,GAA2B,MAAM,CAAC,QAAQ,CAAC;AACtE,MAAM,CAAC,MAAM,iBAAiB,GAA8B,MAAM,CAAC,WAAW,CAAC;AAC/E,MAAM,CAAC,MAAM,iBAAiB,GAA8B,MAAM,CAAC,WAAW,CAAC"}
|
package/esm/log.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Calculates the natural logarithm of a number (logₑ).
|
|
3
|
+
*
|
|
4
|
+
* @param x The number to calculate the natural logarithm of (logₑ)
|
|
5
|
+
* @returns The natural logarithm of the provided number.
|
|
6
|
+
* @category Logarithmic
|
|
7
|
+
*/
|
|
8
|
+
export declare function log(x: number): number;
|
|
9
|
+
//# sourceMappingURL=log.d.ts.map
|
package/esm/log.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"log.d.ts","sourceRoot":"","sources":["../src/log.ts"],"names":[],"mappings":"AAYA;;;;;;GAMG;AACH,wBAAgB,GAAG,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAsBrC"}
|
package/esm/log.js
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Calculates the natural logarithm of a number (logₑ).
|
|
3
|
+
*
|
|
4
|
+
* @module log
|
|
5
|
+
*/
|
|
6
|
+
import { EPSILON } from "./constants/epsilon.js";
|
|
7
|
+
import { LN2 } from "./constants/ln2.js";
|
|
8
|
+
import { NAN } from "./constants/nan.js";
|
|
9
|
+
import { POSITIVE_INFINITY } from "./constants/positive_infinity.js";
|
|
10
|
+
import { NEGATIVE_INFINITY } from "./constants/negative_infinity.js";
|
|
11
|
+
import { abs } from "./abs.js";
|
|
12
|
+
/**
|
|
13
|
+
* Calculates the natural logarithm of a number (logₑ).
|
|
14
|
+
*
|
|
15
|
+
* @param x The number to calculate the natural logarithm of (logₑ)
|
|
16
|
+
* @returns The natural logarithm of the provided number.
|
|
17
|
+
* @category Logarithmic
|
|
18
|
+
*/
|
|
19
|
+
export function log(x) {
|
|
20
|
+
if ((x = +x) !== x || x < 0)
|
|
21
|
+
return NAN; // NaN for x < 0
|
|
22
|
+
if (x === 0)
|
|
23
|
+
return NEGATIVE_INFINITY; // -Infinity for x <= 0
|
|
24
|
+
if (x === 1)
|
|
25
|
+
return 0; // 0 for x = 1
|
|
26
|
+
if (x === POSITIVE_INFINITY)
|
|
27
|
+
return x; // Infinity for x = Infinity
|
|
28
|
+
const seriesEpsilon = EPSILON * 16;
|
|
29
|
+
let n = 0;
|
|
30
|
+
while (x > 2)
|
|
31
|
+
x /= 2, n++;
|
|
32
|
+
const z = (x - 1) / (x + 1), z2 = z * z;
|
|
33
|
+
let sum = 0, term = z, i = 1;
|
|
34
|
+
// series expansion for ln(1+z) converges faster when z is [-1, 1]
|
|
35
|
+
while (abs(term) >= seriesEpsilon) {
|
|
36
|
+
sum += term / i;
|
|
37
|
+
term *= z2;
|
|
38
|
+
i += 2;
|
|
39
|
+
}
|
|
40
|
+
// ln(x) + adjustment factor for original input
|
|
41
|
+
return 2 * sum + n * LN2;
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=log.js.map
|
package/esm/log.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"log.js","sourceRoot":"","sources":["../src/log.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,GAAG,EAAE,MAAM,oBAAoB,CAAC;AACzC,OAAO,EAAE,GAAG,EAAE,MAAM,oBAAoB,CAAC;AACzC,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AACrE,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AACrE,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAE/B;;;;;;GAMG;AACH,MAAM,UAAU,GAAG,CAAC,CAAS;IAC3B,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC;QAAE,OAAO,GAAG,CAAC,CAAC,gBAAgB;IACzD,IAAI,CAAC,KAAK,CAAC;QAAE,OAAO,iBAAiB,CAAC,CAAC,uBAAuB;IAC9D,IAAI,CAAC,KAAK,CAAC;QAAE,OAAO,CAAC,CAAC,CAAC,cAAc;IACrC,IAAI,CAAC,KAAK,iBAAiB;QAAE,OAAO,CAAC,CAAC,CAAC,4BAA4B;IAEnE,MAAM,aAAa,GAAG,OAAO,GAAG,EAAE,CAAC;IACnC,IAAI,CAAC,GAAG,CAAC,CAAC;IACV,OAAO,CAAC,GAAG,CAAC;QAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC;IAE1B,MAAM,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC;IACxC,IAAI,GAAG,GAAG,CAAC,EAAE,IAAI,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC;IAE7B,kEAAkE;IAClE,OAAO,GAAG,CAAC,IAAI,CAAC,IAAI,aAAa,EAAE,CAAC;QAClC,GAAG,IAAI,IAAI,GAAG,CAAC,CAAC;QAChB,IAAI,IAAI,EAAE,CAAC;QACX,CAAC,IAAI,CAAC,CAAC;IACT,CAAC;IAED,+CAA+C;IAC/C,OAAO,CAAC,GAAG,GAAG,GAAG,CAAC,GAAG,GAAG,CAAC;AAC3B,CAAC"}
|
package/esm/log10.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Calculates the base-10 logarithm of a number.
|
|
3
|
+
*
|
|
4
|
+
* @param x The number to calculate the base-10 logarithm of (log₁₀)
|
|
5
|
+
* @returns The base-10 logarithm of the provided number.
|
|
6
|
+
* @category Logarithmic
|
|
7
|
+
*/
|
|
8
|
+
export declare function log10(x: number): number;
|
|
9
|
+
//# sourceMappingURL=log10.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"log10.d.ts","sourceRoot":"","sources":["../src/log10.ts"],"names":[],"mappings":"AAQA;;;;;;GAMG;AACH,wBAAgB,KAAK,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAEvC"}
|
package/esm/log10.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Calculates the base-10 logarithm of a number.
|
|
3
|
+
*
|
|
4
|
+
* @module log10
|
|
5
|
+
*/
|
|
6
|
+
import { LOG10E } from "./constants/log10e.js";
|
|
7
|
+
import { log } from "./log.js";
|
|
8
|
+
/**
|
|
9
|
+
* Calculates the base-10 logarithm of a number.
|
|
10
|
+
*
|
|
11
|
+
* @param x The number to calculate the base-10 logarithm of (log₁₀)
|
|
12
|
+
* @returns The base-10 logarithm of the provided number.
|
|
13
|
+
* @category Logarithmic
|
|
14
|
+
*/
|
|
15
|
+
export function log10(x) {
|
|
16
|
+
return log(x) * LOG10E;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=log10.js.map
|
package/esm/log10.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"log10.js","sourceRoot":"","sources":["../src/log10.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC/C,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAE/B;;;;;;GAMG;AACH,MAAM,UAAU,KAAK,CAAC,CAAS;IAC7B,OAAO,GAAG,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC;AACzB,CAAC"}
|
package/esm/log1p.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Calculates the natural logarithm of 1 + x (`log(1 + x)`), accurately even
|
|
3
|
+
* for very small values of x.
|
|
4
|
+
*
|
|
5
|
+
* @param x The number whose logarithm of (1 + x) is to be calculated.
|
|
6
|
+
* @returns The natural logarithm of 1 + x.
|
|
7
|
+
* @category Logarithmic
|
|
8
|
+
*/
|
|
9
|
+
export declare function log1p(x: number): number;
|
|
10
|
+
//# sourceMappingURL=log1p.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"log1p.d.ts","sourceRoot":"","sources":["../src/log1p.ts"],"names":[],"mappings":"AAYA;;;;;;;GAOG;AACH,wBAAgB,KAAK,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAKvC"}
|
package/esm/log1p.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Calculates the natural logarithm of 1 + x (`log(1 + x)`), accurately even
|
|
3
|
+
* for very small values of x.
|
|
4
|
+
*
|
|
5
|
+
* @module log1p
|
|
6
|
+
*/
|
|
7
|
+
import { EPSILON } from "./constants/epsilon.js";
|
|
8
|
+
import { NAN } from "./constants/nan.js";
|
|
9
|
+
import { NEGATIVE_INFINITY } from "./constants/negative_infinity.js";
|
|
10
|
+
import { abs } from "./abs.js";
|
|
11
|
+
import { log } from "./log.js";
|
|
12
|
+
/**
|
|
13
|
+
* Calculates the natural logarithm of 1 + x (`log(1 + x)`), accurately even
|
|
14
|
+
* for very small values of x.
|
|
15
|
+
*
|
|
16
|
+
* @param x The number whose logarithm of (1 + x) is to be calculated.
|
|
17
|
+
* @returns The natural logarithm of 1 + x.
|
|
18
|
+
* @category Logarithmic
|
|
19
|
+
*/
|
|
20
|
+
export function log1p(x) {
|
|
21
|
+
if (x === -1)
|
|
22
|
+
return NEGATIVE_INFINITY;
|
|
23
|
+
if (x < -1)
|
|
24
|
+
return NAN;
|
|
25
|
+
if (abs(x) < EPSILON)
|
|
26
|
+
return x;
|
|
27
|
+
return log(1 + x);
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=log1p.js.map
|
package/esm/log1p.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"log1p.js","sourceRoot":"","sources":["../src/log1p.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,GAAG,EAAE,MAAM,oBAAoB,CAAC;AACzC,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AACrE,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAC/B,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAE/B;;;;;;;GAOG;AACH,MAAM,UAAU,KAAK,CAAC,CAAS;IAC7B,IAAI,CAAC,KAAK,CAAC,CAAC;QAAE,OAAO,iBAAiB,CAAC;IACvC,IAAI,CAAC,GAAG,CAAC,CAAC;QAAE,OAAO,GAAG,CAAC;IACvB,IAAI,GAAG,CAAC,CAAC,CAAC,GAAG,OAAO;QAAE,OAAO,CAAC,CAAC;IAC/B,OAAO,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;AACpB,CAAC"}
|
package/esm/log2.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Calculates the base-2 logarithm of a number (log₂).
|
|
3
|
+
*
|
|
4
|
+
* @param x The number to calculate the base-2 logarithm of (log₂)
|
|
5
|
+
* @returns The base-2 logarithm of the provided number.
|
|
6
|
+
* @category Logarithmic
|
|
7
|
+
* @see {@linkcode log} for the natural logarithm.
|
|
8
|
+
* @see {@linkcode log10} for the base-10 logarithm.
|
|
9
|
+
* @see {@linkcode LOG2E} for the base-2 logarithm of {@linkcode E}.
|
|
10
|
+
*/
|
|
11
|
+
export declare function log2(x: number): number;
|
|
12
|
+
//# sourceMappingURL=log2.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"log2.d.ts","sourceRoot":"","sources":["../src/log2.ts"],"names":[],"mappings":"AAQA;;;;;;;;;GASG;AACH,wBAAgB,IAAI,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAEtC"}
|
package/esm/log2.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Calculates the base-2 logarithm of a number (log₂).
|
|
3
|
+
*
|
|
4
|
+
* @module log2
|
|
5
|
+
*/
|
|
6
|
+
import { LOG2E } from "./constants/log2e.js";
|
|
7
|
+
import { log } from "./log.js";
|
|
8
|
+
/**
|
|
9
|
+
* Calculates the base-2 logarithm of a number (log₂).
|
|
10
|
+
*
|
|
11
|
+
* @param x The number to calculate the base-2 logarithm of (log₂)
|
|
12
|
+
* @returns The base-2 logarithm of the provided number.
|
|
13
|
+
* @category Logarithmic
|
|
14
|
+
* @see {@linkcode log} for the natural logarithm.
|
|
15
|
+
* @see {@linkcode log10} for the base-10 logarithm.
|
|
16
|
+
* @see {@linkcode LOG2E} for the base-2 logarithm of {@linkcode E}.
|
|
17
|
+
*/
|
|
18
|
+
export function log2(x) {
|
|
19
|
+
return log(x) * LOG2E;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=log2.js.map
|
package/esm/log2.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"log2.js","sourceRoot":"","sources":["../src/log2.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAC7C,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAE/B;;;;;;;;;GASG;AACH,MAAM,UAAU,IAAI,CAAC,CAAS;IAC5B,OAAO,GAAG,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC;AACxB,CAAC"}
|