@ac-kit/math-numbers 0.1.1 → 0.2.1

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.
Files changed (126) hide show
  1. package/CHANGELOG.md +52 -0
  2. package/README.md +1 -1
  3. package/dist/fixed-int-big/_validate-bit-width.d.ts +10 -0
  4. package/dist/fixed-int-big/_validate-bit-width.d.ts.map +1 -0
  5. package/dist/fixed-int-big/_validate-bit-width.js +14 -0
  6. package/dist/fixed-int-big/_validate-bit-width.js.map +1 -0
  7. package/dist/fixed-int-big/_validate-shift-count.d.ts +10 -0
  8. package/dist/fixed-int-big/_validate-shift-count.d.ts.map +1 -0
  9. package/dist/fixed-int-big/_validate-shift-count.js +14 -0
  10. package/dist/fixed-int-big/_validate-shift-count.js.map +1 -0
  11. package/dist/fixed-int-big/fixed-sint-big-abs.d.ts +16 -0
  12. package/dist/fixed-int-big/fixed-sint-big-abs.d.ts.map +1 -0
  13. package/dist/fixed-int-big/fixed-sint-big-abs.js +19 -0
  14. package/dist/fixed-int-big/fixed-sint-big-abs.js.map +1 -0
  15. package/dist/fixed-int-big/fixed-sint-big-add.d.ts +14 -0
  16. package/dist/fixed-int-big/fixed-sint-big-add.d.ts.map +1 -0
  17. package/dist/fixed-int-big/fixed-sint-big-add.js +16 -0
  18. package/dist/fixed-int-big/fixed-sint-big-add.js.map +1 -0
  19. package/dist/fixed-int-big/fixed-sint-big-div.d.ts +24 -0
  20. package/dist/fixed-int-big/fixed-sint-big-div.d.ts.map +1 -0
  21. package/dist/fixed-int-big/fixed-sint-big-div.js +27 -0
  22. package/dist/fixed-int-big/fixed-sint-big-div.js.map +1 -0
  23. package/dist/fixed-int-big/fixed-sint-big-from.d.ts +27 -0
  24. package/dist/fixed-int-big/fixed-sint-big-from.d.ts.map +1 -0
  25. package/dist/fixed-int-big/fixed-sint-big-from.js +46 -0
  26. package/dist/fixed-int-big/fixed-sint-big-from.js.map +1 -0
  27. package/dist/fixed-int-big/fixed-sint-big-is-in-range.d.ts +10 -0
  28. package/dist/fixed-int-big/fixed-sint-big-is-in-range.d.ts.map +1 -0
  29. package/dist/fixed-int-big/fixed-sint-big-is-in-range.js +16 -0
  30. package/dist/fixed-int-big/fixed-sint-big-is-in-range.js.map +1 -0
  31. package/dist/fixed-int-big/fixed-sint-big-max.d.ts +13 -0
  32. package/dist/fixed-int-big/fixed-sint-big-max.d.ts.map +1 -0
  33. package/dist/fixed-int-big/fixed-sint-big-max.js +19 -0
  34. package/dist/fixed-int-big/fixed-sint-big-max.js.map +1 -0
  35. package/dist/fixed-int-big/fixed-sint-big-min.d.ts +14 -0
  36. package/dist/fixed-int-big/fixed-sint-big-min.d.ts.map +1 -0
  37. package/dist/fixed-int-big/fixed-sint-big-min.js +19 -0
  38. package/dist/fixed-int-big/fixed-sint-big-min.js.map +1 -0
  39. package/dist/fixed-int-big/fixed-sint-big-mul.d.ts +19 -0
  40. package/dist/fixed-int-big/fixed-sint-big-mul.d.ts.map +1 -0
  41. package/dist/fixed-int-big/fixed-sint-big-mul.js +21 -0
  42. package/dist/fixed-int-big/fixed-sint-big-mul.js.map +1 -0
  43. package/dist/fixed-int-big/fixed-sint-big-neg.d.ts +17 -0
  44. package/dist/fixed-int-big/fixed-sint-big-neg.d.ts.map +1 -0
  45. package/dist/fixed-int-big/fixed-sint-big-neg.js +19 -0
  46. package/dist/fixed-int-big/fixed-sint-big-neg.js.map +1 -0
  47. package/dist/fixed-int-big/fixed-sint-big-pop-count.d.ts +15 -0
  48. package/dist/fixed-int-big/fixed-sint-big-pop-count.d.ts.map +1 -0
  49. package/dist/fixed-int-big/fixed-sint-big-pop-count.js +19 -0
  50. package/dist/fixed-int-big/fixed-sint-big-pop-count.js.map +1 -0
  51. package/dist/fixed-int-big/fixed-sint-big-rem.d.ts +19 -0
  52. package/dist/fixed-int-big/fixed-sint-big-rem.d.ts.map +1 -0
  53. package/dist/fixed-int-big/fixed-sint-big-rem.js +24 -0
  54. package/dist/fixed-int-big/fixed-sint-big-rem.js.map +1 -0
  55. package/dist/fixed-int-big/fixed-sint-big-shift-left.d.ts +20 -0
  56. package/dist/fixed-int-big/fixed-sint-big-shift-left.d.ts.map +1 -0
  57. package/dist/fixed-int-big/fixed-sint-big-shift-left.js +24 -0
  58. package/dist/fixed-int-big/fixed-sint-big-shift-left.js.map +1 -0
  59. package/dist/fixed-int-big/fixed-sint-big-shift-right.d.ts +16 -0
  60. package/dist/fixed-int-big/fixed-sint-big-shift-right.d.ts.map +1 -0
  61. package/dist/fixed-int-big/fixed-sint-big-shift-right.js +20 -0
  62. package/dist/fixed-int-big/fixed-sint-big-shift-right.js.map +1 -0
  63. package/dist/fixed-int-big/fixed-sint-big-sub.d.ts +15 -0
  64. package/dist/fixed-int-big/fixed-sint-big-sub.d.ts.map +1 -0
  65. package/dist/fixed-int-big/fixed-sint-big-sub.js +17 -0
  66. package/dist/fixed-int-big/fixed-sint-big-sub.js.map +1 -0
  67. package/dist/fixed-int-big/fixed-sint-big-to-unsigned.d.ts +18 -0
  68. package/dist/fixed-int-big/fixed-sint-big-to-unsigned.d.ts.map +1 -0
  69. package/dist/fixed-int-big/fixed-sint-big-to-unsigned.js +22 -0
  70. package/dist/fixed-int-big/fixed-sint-big-to-unsigned.js.map +1 -0
  71. package/dist/fixed-int-big/fixed-sint-big-unsigned-shift-right.d.ts +17 -0
  72. package/dist/fixed-int-big/fixed-sint-big-unsigned-shift-right.d.ts.map +1 -0
  73. package/dist/fixed-int-big/fixed-sint-big-unsigned-shift-right.js +24 -0
  74. package/dist/fixed-int-big/fixed-sint-big-unsigned-shift-right.js.map +1 -0
  75. package/dist/fixed-int-big/fixed-uint-big-add.d.ts +14 -0
  76. package/dist/fixed-int-big/fixed-uint-big-add.d.ts.map +1 -0
  77. package/dist/fixed-int-big/fixed-uint-big-add.js +16 -0
  78. package/dist/fixed-int-big/fixed-uint-big-add.js.map +1 -0
  79. package/dist/fixed-int-big/fixed-uint-big-from.d.ts +20 -0
  80. package/dist/fixed-int-big/fixed-uint-big-from.d.ts.map +1 -0
  81. package/dist/fixed-int-big/fixed-uint-big-from.js +37 -0
  82. package/dist/fixed-int-big/fixed-uint-big-from.js.map +1 -0
  83. package/dist/fixed-int-big/fixed-uint-big-is-in-range.d.ts +10 -0
  84. package/dist/fixed-int-big/fixed-uint-big-is-in-range.d.ts.map +1 -0
  85. package/dist/fixed-int-big/fixed-uint-big-is-in-range.js +15 -0
  86. package/dist/fixed-int-big/fixed-uint-big-is-in-range.js.map +1 -0
  87. package/dist/fixed-int-big/fixed-uint-big-max.d.ts +17 -0
  88. package/dist/fixed-int-big/fixed-uint-big-max.d.ts.map +1 -0
  89. package/dist/fixed-int-big/fixed-uint-big-max.js +19 -0
  90. package/dist/fixed-int-big/fixed-uint-big-max.js.map +1 -0
  91. package/dist/fixed-int-big/fixed-uint-big-mul.d.ts +18 -0
  92. package/dist/fixed-int-big/fixed-uint-big-mul.d.ts.map +1 -0
  93. package/dist/fixed-int-big/fixed-uint-big-mul.js +20 -0
  94. package/dist/fixed-int-big/fixed-uint-big-mul.js.map +1 -0
  95. package/dist/fixed-int-big/fixed-uint-big-neg.d.ts +17 -0
  96. package/dist/fixed-int-big/fixed-uint-big-neg.d.ts.map +1 -0
  97. package/dist/fixed-int-big/fixed-uint-big-neg.js +19 -0
  98. package/dist/fixed-int-big/fixed-uint-big-neg.js.map +1 -0
  99. package/dist/fixed-int-big/fixed-uint-big-not.d.ts +16 -0
  100. package/dist/fixed-int-big/fixed-uint-big-not.d.ts.map +1 -0
  101. package/dist/fixed-int-big/fixed-uint-big-not.js +20 -0
  102. package/dist/fixed-int-big/fixed-uint-big-not.js.map +1 -0
  103. package/dist/fixed-int-big/fixed-uint-big-shift-left.d.ts +19 -0
  104. package/dist/fixed-int-big/fixed-uint-big-shift-left.d.ts.map +1 -0
  105. package/dist/fixed-int-big/fixed-uint-big-shift-left.js +23 -0
  106. package/dist/fixed-int-big/fixed-uint-big-shift-left.js.map +1 -0
  107. package/dist/fixed-int-big/fixed-uint-big-shift-right.d.ts +15 -0
  108. package/dist/fixed-int-big/fixed-uint-big-shift-right.d.ts.map +1 -0
  109. package/dist/fixed-int-big/fixed-uint-big-shift-right.js +19 -0
  110. package/dist/fixed-int-big/fixed-uint-big-shift-right.js.map +1 -0
  111. package/dist/fixed-int-big/fixed-uint-big-sub.d.ts +19 -0
  112. package/dist/fixed-int-big/fixed-uint-big-sub.d.ts.map +1 -0
  113. package/dist/fixed-int-big/fixed-uint-big-sub.js +21 -0
  114. package/dist/fixed-int-big/fixed-uint-big-sub.js.map +1 -0
  115. package/dist/fixed-int-big/fixed-uint-big-to-signed.d.ts +13 -0
  116. package/dist/fixed-int-big/fixed-uint-big-to-signed.d.ts.map +1 -0
  117. package/dist/fixed-int-big/fixed-uint-big-to-signed.js +17 -0
  118. package/dist/fixed-int-big/fixed-uint-big-to-signed.js.map +1 -0
  119. package/dist/ieee754/binary/kernels/wasm/_wasm-bytes.generated.d.ts +1 -1
  120. package/dist/ieee754/binary/kernels/wasm/_wasm-bytes.generated.js +1 -1
  121. package/dist/ieee754/binary/kernels/wasm/_wasm-bytes.generated.js.map +1 -1
  122. package/dist/index.d.ts +27 -0
  123. package/dist/index.d.ts.map +1 -1
  124. package/dist/index.js +27 -0
  125. package/dist/index.js.map +1 -1
  126. package/package.json +10 -10
package/CHANGELOG.md CHANGED
@@ -1,5 +1,57 @@
1
1
  # @ac-kit/math-numbers
2
2
 
3
+ ## 0.2.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [aca1cb1]
8
+ - @ac-kit/core@0.4.0
9
+ - @ac-kit/math-algebra@0.1.3
10
+ - @ac-kit/math-integer@0.2.1
11
+
12
+ ## 0.2.0
13
+
14
+ ### Minor Changes
15
+
16
+ - a5c4d66: New `fixed-int-big/`: `bigint`-backed fixed-width integer arithmetic.
17
+
18
+ `fixedSIntBig*` and `fixedUIntBig*` are the signed and unsigned surfaces — range
19
+ queries, the `*From` overflow gates, arithmetic, shifts, and the two
20
+ reinterpretations between a value and its bit pattern.
21
+
22
+ Every operation takes `(value, bitWidth, mode?)`, or `(left, right, bitWidth,
23
+ mode?)` when binary. The width is mandatory because the same `bigint` is a
24
+ different number at 64 and at 128 bits; the mode is optional and falls back to
25
+ `numericConfig.defaultOverflowMode`, read on each call so changing the global
26
+ takes effect immediately. One default at every width, so the same expression
27
+ cannot mean different things depending on the type it was written for.
28
+
29
+ Any non-negative width is legal, zero included: a zero-bit integer holds exactly
30
+ one value, `0n`, whichever overflow mode is asked for, which is what a `/0`
31
+ netmask and any other empty field need. Only the operations that admit a value
32
+ reject a bad width — the `*From` gates and the two `*IsInRange` queries throw
33
+ `RangeError` unless the width is a non-negative safe integer. `fixedUIntBigMax`,
34
+ `fixedSIntBigMax` and `fixedSIntBigMin` take a width and nothing else, so they
35
+ validate nothing and an out-of-domain width is the caller's to avoid.
36
+
37
+ Overflow is decided against the exact result rather than against one a hardware
38
+ multiply has already truncated, so `clamp` saturates at the true value:
39
+ `fixedSIntBigMul(16n, 16n, 8, "clamp")` is `127n`, not the `0n` the low eight
40
+ bits of 256 would give.
41
+
42
+ Nothing is included that would forward to an operator: `&`, `|` and `^` are
43
+ closed over both ranges, a signed `~v` is already in range, and an unsigned
44
+ quotient of two in-range values cannot overflow. `fixedUIntBigNot` exists
45
+ because the unsigned complement is the one that does not fit.
46
+
47
+ ### Patch Changes
48
+
49
+ - Updated dependencies [a5c4d66]
50
+ - Updated dependencies [a5c4d66]
51
+ - @ac-kit/core@0.3.0
52
+ - @ac-kit/math-integer@0.2.0
53
+ - @ac-kit/math-algebra@0.1.2
54
+
3
55
  ## 0.1.1
4
56
 
5
57
  ### Patch Changes
package/README.md CHANGED
@@ -107,5 +107,5 @@ DECIMAL_CONTEXT_IEEE_DECIMAL64.precision; // 16
107
107
  ```
108
108
 
109
109
  See the
110
- [generated API docs](https://anthochamp.github.io/node-essentials/api/math-numbers/)
110
+ [generated API docs](https://anthochamp.pages.grenadine.io/node-essentials/api/math-numbers/)
111
111
  for the full reference.
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Guards the entry points that fit a value to a width. The range queries
3
+ * ({@link fixedUIntBigMax} and the signed pair) are pure functions of the width
4
+ * and answer for a zero-bit integer as readily as any other, so they do not
5
+ * call this.
6
+ *
7
+ * @throws {RangeError} When `bitWidth` is not a non-negative safe integer.
8
+ */
9
+ export declare function validateBitWidth(bitWidth: number): void;
10
+ //# sourceMappingURL=_validate-bit-width.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"_validate-bit-width.d.ts","sourceRoot":"","sources":["../../src/fixed-int-big/_validate-bit-width.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAMvD"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Guards the entry points that fit a value to a width. The range queries
3
+ * ({@link fixedUIntBigMax} and the signed pair) are pure functions of the width
4
+ * and answer for a zero-bit integer as readily as any other, so they do not
5
+ * call this.
6
+ *
7
+ * @throws {RangeError} When `bitWidth` is not a non-negative safe integer.
8
+ */
9
+ export function validateBitWidth(bitWidth) {
10
+ if (!Number.isSafeInteger(bitWidth) || bitWidth < 0) {
11
+ throw new RangeError(`bit width must be a non-negative integer, got ${bitWidth}`);
12
+ }
13
+ }
14
+ //# sourceMappingURL=_validate-bit-width.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"_validate-bit-width.js","sourceRoot":"","sources":["../../src/fixed-int-big/_validate-bit-width.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,MAAM,UAAU,gBAAgB,CAAC,QAAgB;IAChD,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,QAAQ,CAAC,IAAI,QAAQ,GAAG,CAAC,EAAE,CAAC;QACrD,MAAM,IAAI,UAAU,CACnB,iDAAiD,QAAQ,EAAE,CAC3D,CAAC;IACH,CAAC;AACF,CAAC"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Rejects a shift count no shift here accepts.
3
+ *
4
+ * A negative count is the reason this exists: `bigint`'s `>>` shifts the other
5
+ * way rather than throwing, so `value >> -2n` silently multiplies by four.
6
+ *
7
+ * @throws {RangeError} When `count` is not a non-negative safe integer.
8
+ */
9
+ export declare function validateShiftCount(count: number): void;
10
+ //# sourceMappingURL=_validate-shift-count.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"_validate-shift-count.d.ts","sourceRoot":"","sources":["../../src/fixed-int-big/_validate-shift-count.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAMtD"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Rejects a shift count no shift here accepts.
3
+ *
4
+ * A negative count is the reason this exists: `bigint`'s `>>` shifts the other
5
+ * way rather than throwing, so `value >> -2n` silently multiplies by four.
6
+ *
7
+ * @throws {RangeError} When `count` is not a non-negative safe integer.
8
+ */
9
+ export function validateShiftCount(count) {
10
+ if (!Number.isSafeInteger(count) || count < 0) {
11
+ throw new RangeError(`shift count must be a non-negative integer, got ${count}`);
12
+ }
13
+ }
14
+ //# sourceMappingURL=_validate-shift-count.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"_validate-shift-count.js","sourceRoot":"","sources":["../../src/fixed-int-big/_validate-shift-count.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,MAAM,UAAU,kBAAkB,CAAC,KAAa;IAC/C,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC,IAAI,KAAK,GAAG,CAAC,EAAE,CAAC;QAC/C,MAAM,IAAI,UAAU,CACnB,mDAAmD,KAAK,EAAE,CAC1D,CAAC;IACH,CAAC;AACF,CAAC"}
@@ -0,0 +1,16 @@
1
+ import type { OverflowMode } from "../overflow-mode.js";
2
+ /**
3
+ * Absolute value of a `bitWidth`-bit two's-complement integer, under `mode`.
4
+ *
5
+ * Overflows for exactly one input, for the same reason {@link fixedSIntBigNeg}
6
+ * does: the minimum's magnitude is one past the maximum.
7
+ *
8
+ * @param value - The value to take the magnitude of.
9
+ * @param bitWidth - Width of the integer, in bits.
10
+ * @param mode - Overflow policy. Defaults to
11
+ * `numericConfig.defaultOverflowMode`.
12
+ * @throws {RangeError} When `bitWidth` is not a non-negative safe integer.
13
+ * @throws {OverflowError} When `value` is the minimum and `mode` is `abort`.
14
+ */
15
+ export declare function fixedSIntBigAbs(value: bigint, bitWidth: number, mode?: OverflowMode): bigint;
16
+ //# sourceMappingURL=fixed-sint-big-abs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fixed-sint-big-abs.d.ts","sourceRoot":"","sources":["../../src/fixed-int-big/fixed-sint-big-abs.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAGxD;;;;;;;;;;;;GAYG;AACH,wBAAgB,eAAe,CAC9B,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,MAAM,EAChB,IAAI,CAAC,EAAE,YAAY,GACjB,MAAM,CAER"}
@@ -0,0 +1,19 @@
1
+ import { bigIntAbs } from "@ac-kit/core";
2
+ import { fixedSIntBigFrom } from "./fixed-sint-big-from.js";
3
+ /**
4
+ * Absolute value of a `bitWidth`-bit two's-complement integer, under `mode`.
5
+ *
6
+ * Overflows for exactly one input, for the same reason {@link fixedSIntBigNeg}
7
+ * does: the minimum's magnitude is one past the maximum.
8
+ *
9
+ * @param value - The value to take the magnitude of.
10
+ * @param bitWidth - Width of the integer, in bits.
11
+ * @param mode - Overflow policy. Defaults to
12
+ * `numericConfig.defaultOverflowMode`.
13
+ * @throws {RangeError} When `bitWidth` is not a non-negative safe integer.
14
+ * @throws {OverflowError} When `value` is the minimum and `mode` is `abort`.
15
+ */
16
+ export function fixedSIntBigAbs(value, bitWidth, mode) {
17
+ return fixedSIntBigFrom(bigIntAbs(value), bitWidth, mode);
18
+ }
19
+ //# sourceMappingURL=fixed-sint-big-abs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fixed-sint-big-abs.js","sourceRoot":"","sources":["../../src/fixed-int-big/fixed-sint-big-abs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAGzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAE5D;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,eAAe,CAC9B,KAAa,EACb,QAAgB,EAChB,IAAmB;IAEnB,OAAO,gBAAgB,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,QAAQ,EAAE,IAAI,CAAC,CAAC;AAC3D,CAAC"}
@@ -0,0 +1,14 @@
1
+ import type { OverflowMode } from "../overflow-mode.js";
2
+ /**
3
+ * Sum of two `bitWidth`-bit two's-complement integers, under `mode`.
4
+ *
5
+ * @param left - Left operand.
6
+ * @param right - Right operand.
7
+ * @param bitWidth - Width of the integer, in bits.
8
+ * @param mode - Overflow policy. Defaults to
9
+ * `numericConfig.defaultOverflowMode`.
10
+ * @throws {RangeError} When `bitWidth` is not a non-negative safe integer.
11
+ * @throws {OverflowError} When the sum does not fit and `mode` is `abort`.
12
+ */
13
+ export declare function fixedSIntBigAdd(left: bigint, right: bigint, bitWidth: number, mode?: OverflowMode): bigint;
14
+ //# sourceMappingURL=fixed-sint-big-add.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fixed-sint-big-add.d.ts","sourceRoot":"","sources":["../../src/fixed-int-big/fixed-sint-big-add.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAGxD;;;;;;;;;;GAUG;AACH,wBAAgB,eAAe,CAC9B,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,MAAM,EAChB,IAAI,CAAC,EAAE,YAAY,GACjB,MAAM,CAER"}
@@ -0,0 +1,16 @@
1
+ import { fixedSIntBigFrom } from "./fixed-sint-big-from.js";
2
+ /**
3
+ * Sum of two `bitWidth`-bit two's-complement integers, under `mode`.
4
+ *
5
+ * @param left - Left operand.
6
+ * @param right - Right operand.
7
+ * @param bitWidth - Width of the integer, in bits.
8
+ * @param mode - Overflow policy. Defaults to
9
+ * `numericConfig.defaultOverflowMode`.
10
+ * @throws {RangeError} When `bitWidth` is not a non-negative safe integer.
11
+ * @throws {OverflowError} When the sum does not fit and `mode` is `abort`.
12
+ */
13
+ export function fixedSIntBigAdd(left, right, bitWidth, mode) {
14
+ return fixedSIntBigFrom(left + right, bitWidth, mode);
15
+ }
16
+ //# sourceMappingURL=fixed-sint-big-add.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fixed-sint-big-add.js","sourceRoot":"","sources":["../../src/fixed-int-big/fixed-sint-big-add.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAE5D;;;;;;;;;;GAUG;AACH,MAAM,UAAU,eAAe,CAC9B,IAAY,EACZ,KAAa,EACb,QAAgB,EAChB,IAAmB;IAEnB,OAAO,gBAAgB,CAAC,IAAI,GAAG,KAAK,EAAE,QAAQ,EAAE,IAAI,CAAC,CAAC;AACvD,CAAC"}
@@ -0,0 +1,24 @@
1
+ import type { OverflowMode } from "../overflow-mode.js";
2
+ /**
3
+ * Quotient of two `bitWidth`-bit two's-complement integers, truncated toward
4
+ * zero, under `mode`.
5
+ *
6
+ * Division overflows for exactly one pair — the minimum over `-1`, whose exact
7
+ * quotient is one past the maximum. Division by zero is not overflow but an
8
+ * undefined operation, so it throws `RangeError` whatever `mode` says.
9
+ *
10
+ * There is no unsigned counterpart: an unsigned quotient of two in-range values
11
+ * is never larger than the dividend, so it cannot overflow and would be
12
+ * `bigIntDivTrunc` under another name.
13
+ *
14
+ * @param left - Dividend.
15
+ * @param right - Divisor.
16
+ * @param bitWidth - Width of the integer, in bits.
17
+ * @param mode - Overflow policy. Defaults to
18
+ * `numericConfig.defaultOverflowMode`.
19
+ * @throws {RangeError} When `right` is zero, or `bitWidth` is not a
20
+ * non-negative safe integer.
21
+ * @throws {OverflowError} When the quotient does not fit and `mode` is `abort`.
22
+ */
23
+ export declare function fixedSIntBigDiv(left: bigint, right: bigint, bitWidth: number, mode?: OverflowMode): bigint;
24
+ //# sourceMappingURL=fixed-sint-big-div.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fixed-sint-big-div.d.ts","sourceRoot":"","sources":["../../src/fixed-int-big/fixed-sint-big-div.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAGxD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,eAAe,CAC9B,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,MAAM,EAChB,IAAI,CAAC,EAAE,YAAY,GACjB,MAAM,CAER"}
@@ -0,0 +1,27 @@
1
+ import { bigIntDivTrunc } from "@ac-kit/core";
2
+ import { fixedSIntBigFrom } from "./fixed-sint-big-from.js";
3
+ /**
4
+ * Quotient of two `bitWidth`-bit two's-complement integers, truncated toward
5
+ * zero, under `mode`.
6
+ *
7
+ * Division overflows for exactly one pair — the minimum over `-1`, whose exact
8
+ * quotient is one past the maximum. Division by zero is not overflow but an
9
+ * undefined operation, so it throws `RangeError` whatever `mode` says.
10
+ *
11
+ * There is no unsigned counterpart: an unsigned quotient of two in-range values
12
+ * is never larger than the dividend, so it cannot overflow and would be
13
+ * `bigIntDivTrunc` under another name.
14
+ *
15
+ * @param left - Dividend.
16
+ * @param right - Divisor.
17
+ * @param bitWidth - Width of the integer, in bits.
18
+ * @param mode - Overflow policy. Defaults to
19
+ * `numericConfig.defaultOverflowMode`.
20
+ * @throws {RangeError} When `right` is zero, or `bitWidth` is not a
21
+ * non-negative safe integer.
22
+ * @throws {OverflowError} When the quotient does not fit and `mode` is `abort`.
23
+ */
24
+ export function fixedSIntBigDiv(left, right, bitWidth, mode) {
25
+ return fixedSIntBigFrom(bigIntDivTrunc(left, right), bitWidth, mode);
26
+ }
27
+ //# sourceMappingURL=fixed-sint-big-div.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fixed-sint-big-div.js","sourceRoot":"","sources":["../../src/fixed-int-big/fixed-sint-big-div.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAG9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAE5D;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,UAAU,eAAe,CAC9B,IAAY,EACZ,KAAa,EACb,QAAgB,EAChB,IAAmB;IAEnB,OAAO,gBAAgB,CAAC,cAAc,CAAC,IAAI,EAAE,KAAK,CAAC,EAAE,QAAQ,EAAE,IAAI,CAAC,CAAC;AACtE,CAAC"}
@@ -0,0 +1,27 @@
1
+ import { type OverflowMode } from "../overflow-mode.js";
2
+ /**
3
+ * Brings an arbitrary `bigint` into a `bitWidth`-bit two's-complement integer
4
+ * under `mode`.
5
+ *
6
+ * Every signed operation in this directory ends here: each one computes its
7
+ * exact `bigint` result, which cannot overflow, and hands it over to be fitted.
8
+ * That is what keeps the overflow policy in one place instead of once per
9
+ * operation.
10
+ *
11
+ * `mode` is read from {@link numericConfig} when omitted, and read on each call
12
+ * rather than captured, so changing the global takes effect immediately. One
13
+ * default at every width, deliberately: a policy that changed at 64 bits would
14
+ * make the same expression mean different things depending on the type it was
15
+ * written for.
16
+ *
17
+ * @param value - The exact value to fit.
18
+ * @param bitWidth - Width of the integer, in bits.
19
+ * @param mode - Overflow policy. Defaults to
20
+ * `numericConfig.defaultOverflowMode`.
21
+ * @returns `value` itself when it already fits, and otherwise the wrapped,
22
+ * clamped or (for `abort`) never-returned result.
23
+ * @throws {RangeError} When `bitWidth` is not a non-negative safe integer.
24
+ * @throws {OverflowError} When `value` does not fit and `mode` is `abort`.
25
+ */
26
+ export declare function fixedSIntBigFrom(value: bigint, bitWidth: number, mode?: OverflowMode): bigint;
27
+ //# sourceMappingURL=fixed-sint-big-from.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fixed-sint-big-from.d.ts","sourceRoot":"","sources":["../../src/fixed-int-big/fixed-sint-big-from.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,YAAY,EAAiB,MAAM,qBAAqB,CAAC;AAKvE;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,gBAAgB,CAC/B,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,MAAM,EAChB,IAAI,GAAE,YAAgD,GACpD,MAAM,CAoBR"}
@@ -0,0 +1,46 @@
1
+ import { numericConfig } from "../globals.js";
2
+ import { OverflowError } from "../overflow-mode.js";
3
+ import { validateBitWidth } from "./_validate-bit-width.js";
4
+ import { fixedSIntBigMax } from "./fixed-sint-big-max.js";
5
+ import { fixedSIntBigMin } from "./fixed-sint-big-min.js";
6
+ /**
7
+ * Brings an arbitrary `bigint` into a `bitWidth`-bit two's-complement integer
8
+ * under `mode`.
9
+ *
10
+ * Every signed operation in this directory ends here: each one computes its
11
+ * exact `bigint` result, which cannot overflow, and hands it over to be fitted.
12
+ * That is what keeps the overflow policy in one place instead of once per
13
+ * operation.
14
+ *
15
+ * `mode` is read from {@link numericConfig} when omitted, and read on each call
16
+ * rather than captured, so changing the global takes effect immediately. One
17
+ * default at every width, deliberately: a policy that changed at 64 bits would
18
+ * make the same expression mean different things depending on the type it was
19
+ * written for.
20
+ *
21
+ * @param value - The exact value to fit.
22
+ * @param bitWidth - Width of the integer, in bits.
23
+ * @param mode - Overflow policy. Defaults to
24
+ * `numericConfig.defaultOverflowMode`.
25
+ * @returns `value` itself when it already fits, and otherwise the wrapped,
26
+ * clamped or (for `abort`) never-returned result.
27
+ * @throws {RangeError} When `bitWidth` is not a non-negative safe integer.
28
+ * @throws {OverflowError} When `value` does not fit and `mode` is `abort`.
29
+ */
30
+ export function fixedSIntBigFrom(value, bitWidth, mode = numericConfig.defaultOverflowMode) {
31
+ validateBitWidth(bitWidth);
32
+ const min = fixedSIntBigMin(bitWidth);
33
+ const max = fixedSIntBigMax(bitWidth);
34
+ if (value >= min && value <= max) {
35
+ return value;
36
+ }
37
+ switch (mode) {
38
+ case "wrap":
39
+ return BigInt.asIntN(bitWidth, value);
40
+ case "clamp":
41
+ return value < min ? min : max;
42
+ case "abort":
43
+ throw new OverflowError(`${value} does not fit a ${bitWidth}-bit signed integer`);
44
+ }
45
+ }
46
+ //# sourceMappingURL=fixed-sint-big-from.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fixed-sint-big-from.js","sourceRoot":"","sources":["../../src/fixed-int-big/fixed-sint-big-from.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAqB,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACvE,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAE1D;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,UAAU,gBAAgB,CAC/B,KAAa,EACb,QAAgB,EAChB,IAAI,GAAiB,aAAa,CAAC,mBAAmB;IAEtD,gBAAgB,CAAC,QAAQ,CAAC,CAAC;IAE3B,MAAM,GAAG,GAAG,eAAe,CAAC,QAAQ,CAAC,CAAC;IACtC,MAAM,GAAG,GAAG,eAAe,CAAC,QAAQ,CAAC,CAAC;IAEtC,IAAI,KAAK,IAAI,GAAG,IAAI,KAAK,IAAI,GAAG,EAAE,CAAC;QAClC,OAAO,KAAK,CAAC;IACd,CAAC;IAED,QAAQ,IAAI,EAAE,CAAC;QACd,KAAK,MAAM;YACV,OAAO,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;QACvC,KAAK,OAAO;YACX,OAAO,KAAK,GAAG,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC;QAChC,KAAK,OAAO;YACX,MAAM,IAAI,aAAa,CACtB,GAAG,KAAK,mBAAmB,QAAQ,qBAAqB,CACxD,CAAC;IACJ,CAAC;AACF,CAAC"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Whether `value` already fits a `bitWidth`-bit two's-complement integer, so no
3
+ * overflow policy has to be consulted.
4
+ *
5
+ * @param value - The value to test.
6
+ * @param bitWidth - Width of the integer, in bits.
7
+ * @throws {RangeError} When `bitWidth` is not a non-negative safe integer.
8
+ */
9
+ export declare function fixedSIntBigIsInRange(value: bigint, bitWidth: number): boolean;
10
+ //# sourceMappingURL=fixed-sint-big-is-in-range.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fixed-sint-big-is-in-range.d.ts","sourceRoot":"","sources":["../../src/fixed-int-big/fixed-sint-big-is-in-range.ts"],"names":[],"mappings":"AAIA;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CACpC,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,MAAM,GACd,OAAO,CAMT"}
@@ -0,0 +1,16 @@
1
+ import { validateBitWidth } from "./_validate-bit-width.js";
2
+ import { fixedSIntBigMax } from "./fixed-sint-big-max.js";
3
+ import { fixedSIntBigMin } from "./fixed-sint-big-min.js";
4
+ /**
5
+ * Whether `value` already fits a `bitWidth`-bit two's-complement integer, so no
6
+ * overflow policy has to be consulted.
7
+ *
8
+ * @param value - The value to test.
9
+ * @param bitWidth - Width of the integer, in bits.
10
+ * @throws {RangeError} When `bitWidth` is not a non-negative safe integer.
11
+ */
12
+ export function fixedSIntBigIsInRange(value, bitWidth) {
13
+ validateBitWidth(bitWidth);
14
+ return (value >= fixedSIntBigMin(bitWidth) && value <= fixedSIntBigMax(bitWidth));
15
+ }
16
+ //# sourceMappingURL=fixed-sint-big-is-in-range.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fixed-sint-big-is-in-range.js","sourceRoot":"","sources":["../../src/fixed-int-big/fixed-sint-big-is-in-range.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAE1D;;;;;;;GAOG;AACH,MAAM,UAAU,qBAAqB,CACpC,KAAa,EACb,QAAgB;IAEhB,gBAAgB,CAAC,QAAQ,CAAC,CAAC;IAE3B,OAAO,CACN,KAAK,IAAI,eAAe,CAAC,QAAQ,CAAC,IAAI,KAAK,IAAI,eAAe,CAAC,QAAQ,CAAC,CACxE,CAAC;AACH,CAAC"}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * The largest value a `bitWidth`-bit two's-complement integer holds: `2 **
3
+ * (bitWidth - 1) - 1`.
4
+ *
5
+ * A width of zero holds only `0n`, so it meets {@link fixedSIntBigMin} there
6
+ * instead of sitting one below it. Widths outside the non-negative integers are
7
+ * not part of the domain and are not rejected: unlike {@link fixedSIntBigFrom},
8
+ * this admits no value and so has nothing to guard.
9
+ *
10
+ * @param bitWidth - Width of the integer, in bits.
11
+ */
12
+ export declare function fixedSIntBigMax(bitWidth: number): bigint;
13
+ //# sourceMappingURL=fixed-sint-big-max.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fixed-sint-big-max.d.ts","sourceRoot":"","sources":["../../src/fixed-int-big/fixed-sint-big-max.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAOxD"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * The largest value a `bitWidth`-bit two's-complement integer holds: `2 **
3
+ * (bitWidth - 1) - 1`.
4
+ *
5
+ * A width of zero holds only `0n`, so it meets {@link fixedSIntBigMin} there
6
+ * instead of sitting one below it. Widths outside the non-negative integers are
7
+ * not part of the domain and are not rejected: unlike {@link fixedSIntBigFrom},
8
+ * this admits no value and so has nothing to guard.
9
+ *
10
+ * @param bitWidth - Width of the integer, in bits.
11
+ */
12
+ export function fixedSIntBigMax(bitWidth) {
13
+ // `1n << -1n` shifts right rather than throwing, and would answer `-1n`.
14
+ if (bitWidth === 0) {
15
+ return 0n;
16
+ }
17
+ return (1n << BigInt(bitWidth - 1)) - 1n;
18
+ }
19
+ //# sourceMappingURL=fixed-sint-big-max.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fixed-sint-big-max.js","sourceRoot":"","sources":["../../src/fixed-int-big/fixed-sint-big-max.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,MAAM,UAAU,eAAe,CAAC,QAAgB;IAC/C,yEAAyE;IACzE,IAAI,QAAQ,KAAK,CAAC,EAAE,CAAC;QACpB,OAAO,EAAE,CAAC;IACX,CAAC;IAED,OAAO,CAAC,EAAE,IAAI,MAAM,CAAC,QAAQ,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC;AAC1C,CAAC"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * The most negative value a `bitWidth`-bit two's-complement integer holds: `-(2
3
+ * ** (bitWidth - 1))`.
4
+ *
5
+ * Its magnitude is one larger than {@link fixedSIntBigMax} at every width but
6
+ * zero, which is why negating or taking the absolute value of it overflows. A
7
+ * width of zero holds only `0n`, so the two meet there. Widths outside the
8
+ * non-negative integers are not part of the domain and are not rejected: unlike
9
+ * {@link fixedSIntBigFrom}, this admits no value and so has nothing to guard.
10
+ *
11
+ * @param bitWidth - Width of the integer, in bits.
12
+ */
13
+ export declare function fixedSIntBigMin(bitWidth: number): bigint;
14
+ //# sourceMappingURL=fixed-sint-big-min.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fixed-sint-big-min.d.ts","sourceRoot":"","sources":["../../src/fixed-int-big/fixed-sint-big-min.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAMxD"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * The most negative value a `bitWidth`-bit two's-complement integer holds: `-(2
3
+ * ** (bitWidth - 1))`.
4
+ *
5
+ * Its magnitude is one larger than {@link fixedSIntBigMax} at every width but
6
+ * zero, which is why negating or taking the absolute value of it overflows. A
7
+ * width of zero holds only `0n`, so the two meet there. Widths outside the
8
+ * non-negative integers are not part of the domain and are not rejected: unlike
9
+ * {@link fixedSIntBigFrom}, this admits no value and so has nothing to guard.
10
+ *
11
+ * @param bitWidth - Width of the integer, in bits.
12
+ */
13
+ export function fixedSIntBigMin(bitWidth) {
14
+ if (bitWidth === 0) {
15
+ return 0n;
16
+ }
17
+ return -(1n << BigInt(bitWidth - 1));
18
+ }
19
+ //# sourceMappingURL=fixed-sint-big-min.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fixed-sint-big-min.js","sourceRoot":"","sources":["../../src/fixed-int-big/fixed-sint-big-min.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,eAAe,CAAC,QAAgB;IAC/C,IAAI,QAAQ,KAAK,CAAC,EAAE,CAAC;QACpB,OAAO,EAAE,CAAC;IACX,CAAC;IAED,OAAO,CAAC,CAAC,EAAE,IAAI,MAAM,CAAC,QAAQ,GAAG,CAAC,CAAC,CAAC,CAAC;AACtC,CAAC"}
@@ -0,0 +1,19 @@
1
+ import type { OverflowMode } from "../overflow-mode.js";
2
+ /**
3
+ * Product of two `bitWidth`-bit two's-complement integers, under `mode`.
4
+ *
5
+ * The exact product is computed at full `bigint` width before the policy
6
+ * applies, so `clamp` clamps against the true result rather than against a
7
+ * truncated one — unlike a hardware multiply, which has already lost the high
8
+ * half by the time it can notice.
9
+ *
10
+ * @param left - Left operand.
11
+ * @param right - Right operand.
12
+ * @param bitWidth - Width of the integer, in bits.
13
+ * @param mode - Overflow policy. Defaults to
14
+ * `numericConfig.defaultOverflowMode`.
15
+ * @throws {RangeError} When `bitWidth` is not a non-negative safe integer.
16
+ * @throws {OverflowError} When the product does not fit and `mode` is `abort`.
17
+ */
18
+ export declare function fixedSIntBigMul(left: bigint, right: bigint, bitWidth: number, mode?: OverflowMode): bigint;
19
+ //# sourceMappingURL=fixed-sint-big-mul.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fixed-sint-big-mul.d.ts","sourceRoot":"","sources":["../../src/fixed-int-big/fixed-sint-big-mul.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAGxD;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,eAAe,CAC9B,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,MAAM,EAChB,IAAI,CAAC,EAAE,YAAY,GACjB,MAAM,CAER"}
@@ -0,0 +1,21 @@
1
+ import { fixedSIntBigFrom } from "./fixed-sint-big-from.js";
2
+ /**
3
+ * Product of two `bitWidth`-bit two's-complement integers, under `mode`.
4
+ *
5
+ * The exact product is computed at full `bigint` width before the policy
6
+ * applies, so `clamp` clamps against the true result rather than against a
7
+ * truncated one — unlike a hardware multiply, which has already lost the high
8
+ * half by the time it can notice.
9
+ *
10
+ * @param left - Left operand.
11
+ * @param right - Right operand.
12
+ * @param bitWidth - Width of the integer, in bits.
13
+ * @param mode - Overflow policy. Defaults to
14
+ * `numericConfig.defaultOverflowMode`.
15
+ * @throws {RangeError} When `bitWidth` is not a non-negative safe integer.
16
+ * @throws {OverflowError} When the product does not fit and `mode` is `abort`.
17
+ */
18
+ export function fixedSIntBigMul(left, right, bitWidth, mode) {
19
+ return fixedSIntBigFrom(left * right, bitWidth, mode);
20
+ }
21
+ //# sourceMappingURL=fixed-sint-big-mul.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fixed-sint-big-mul.js","sourceRoot":"","sources":["../../src/fixed-int-big/fixed-sint-big-mul.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAE5D;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,eAAe,CAC9B,IAAY,EACZ,KAAa,EACb,QAAgB,EAChB,IAAmB;IAEnB,OAAO,gBAAgB,CAAC,IAAI,GAAG,KAAK,EAAE,QAAQ,EAAE,IAAI,CAAC,CAAC;AACvD,CAAC"}
@@ -0,0 +1,17 @@
1
+ import type { OverflowMode } from "../overflow-mode.js";
2
+ /**
3
+ * Negation of a `bitWidth`-bit two's-complement integer, under `mode`.
4
+ *
5
+ * Overflows for exactly one input: the minimum has no positive counterpart, so
6
+ * `wrap` returns it unchanged, `clamp` returns the maximum, and `abort`
7
+ * throws.
8
+ *
9
+ * @param value - The value to negate.
10
+ * @param bitWidth - Width of the integer, in bits.
11
+ * @param mode - Overflow policy. Defaults to
12
+ * `numericConfig.defaultOverflowMode`.
13
+ * @throws {RangeError} When `bitWidth` is not a non-negative safe integer.
14
+ * @throws {OverflowError} When `value` is the minimum and `mode` is `abort`.
15
+ */
16
+ export declare function fixedSIntBigNeg(value: bigint, bitWidth: number, mode?: OverflowMode): bigint;
17
+ //# sourceMappingURL=fixed-sint-big-neg.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fixed-sint-big-neg.d.ts","sourceRoot":"","sources":["../../src/fixed-int-big/fixed-sint-big-neg.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAGxD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,eAAe,CAC9B,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,MAAM,EAChB,IAAI,CAAC,EAAE,YAAY,GACjB,MAAM,CAER"}
@@ -0,0 +1,19 @@
1
+ import { fixedSIntBigFrom } from "./fixed-sint-big-from.js";
2
+ /**
3
+ * Negation of a `bitWidth`-bit two's-complement integer, under `mode`.
4
+ *
5
+ * Overflows for exactly one input: the minimum has no positive counterpart, so
6
+ * `wrap` returns it unchanged, `clamp` returns the maximum, and `abort`
7
+ * throws.
8
+ *
9
+ * @param value - The value to negate.
10
+ * @param bitWidth - Width of the integer, in bits.
11
+ * @param mode - Overflow policy. Defaults to
12
+ * `numericConfig.defaultOverflowMode`.
13
+ * @throws {RangeError} When `bitWidth` is not a non-negative safe integer.
14
+ * @throws {OverflowError} When `value` is the minimum and `mode` is `abort`.
15
+ */
16
+ export function fixedSIntBigNeg(value, bitWidth, mode) {
17
+ return fixedSIntBigFrom(-value, bitWidth, mode);
18
+ }
19
+ //# sourceMappingURL=fixed-sint-big-neg.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fixed-sint-big-neg.js","sourceRoot":"","sources":["../../src/fixed-int-big/fixed-sint-big-neg.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAE5D;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,eAAe,CAC9B,KAAa,EACb,QAAgB,EAChB,IAAmB;IAEnB,OAAO,gBAAgB,CAAC,CAAC,KAAK,EAAE,QAAQ,EAAE,IAAI,CAAC,CAAC;AACjD,CAAC"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Set bits in the `bitWidth`-bit two's-complement pattern of `value`: `-1n` at
3
+ * 8 bits answers `8`.
4
+ *
5
+ * Distinct from `@ac-kit/core`'s `bigIntPopCount`, which counts the magnitude
6
+ * and would answer `1` for the same input. Both are right for what they are
7
+ * asked — an unbounded `bigint` has no finite two's-complement pattern to count
8
+ * — and `bitWidth` is exactly what supplies the missing one.
9
+ *
10
+ * @param value - The value to count.
11
+ * @param bitWidth - Width of the integer, in bits.
12
+ * @throws {RangeError} When `bitWidth` is not a non-negative safe integer.
13
+ */
14
+ export declare function fixedSIntBigPopCount(value: bigint, bitWidth: number): number;
15
+ //# sourceMappingURL=fixed-sint-big-pop-count.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fixed-sint-big-pop-count.d.ts","sourceRoot":"","sources":["../../src/fixed-int-big/fixed-sint-big-pop-count.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;GAYG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAE5E"}