functionalscript 0.0.555 → 0.0.556
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/package.json +1 -1
- package/types/bigint/module.f.cjs +4 -4
- package/types/bigint/test.f.cjs +17 -17
package/package.json
CHANGED
|
@@ -45,9 +45,9 @@ const scalar_mul = ({ 0: _0, add }) => a => n => {
|
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
/** @type {(a: bigint) => bigint} */
|
|
48
|
-
const
|
|
49
|
-
let i =
|
|
50
|
-
while (a
|
|
48
|
+
const log2 = a => {
|
|
49
|
+
let i = -1n
|
|
50
|
+
while (a > 0n) {
|
|
51
51
|
++i
|
|
52
52
|
a >>= 1n
|
|
53
53
|
}
|
|
@@ -68,5 +68,5 @@ module.exports = {
|
|
|
68
68
|
/** @readonly */
|
|
69
69
|
scalar_mul,
|
|
70
70
|
/** @readonly */
|
|
71
|
-
|
|
71
|
+
log2,
|
|
72
72
|
}
|
package/types/bigint/test.f.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const { sum, abs, serialize,
|
|
1
|
+
const { sum, abs, serialize, log2 } = require('./module.f.cjs')
|
|
2
2
|
|
|
3
3
|
module.exports = {
|
|
4
4
|
sum: () => {
|
|
@@ -29,42 +29,42 @@ module.exports = {
|
|
|
29
29
|
if (result !== '-55555n') { throw result }
|
|
30
30
|
},
|
|
31
31
|
],
|
|
32
|
-
|
|
32
|
+
log2: [
|
|
33
33
|
() => {
|
|
34
|
-
const result =
|
|
34
|
+
const result = log2(0n)
|
|
35
|
+
if (result !== -1n) { throw result }
|
|
36
|
+
},
|
|
37
|
+
() => {
|
|
38
|
+
const result = log2(1n)
|
|
35
39
|
if (result !== 0n) { throw result }
|
|
36
40
|
},
|
|
37
41
|
() => {
|
|
38
|
-
const result =
|
|
42
|
+
const result = log2(2n)
|
|
39
43
|
if (result !== 1n) { throw result }
|
|
40
44
|
},
|
|
41
45
|
() => {
|
|
42
|
-
const result =
|
|
43
|
-
if (result !==
|
|
46
|
+
const result = log2(3n)
|
|
47
|
+
if (result !== 1n) { throw result }
|
|
44
48
|
},
|
|
45
49
|
() => {
|
|
46
|
-
const result =
|
|
50
|
+
const result = log2(4n)
|
|
47
51
|
if (result !== 2n) { throw result }
|
|
48
52
|
},
|
|
49
53
|
() => {
|
|
50
|
-
const result =
|
|
51
|
-
if (result !==
|
|
54
|
+
const result = log2(7n)
|
|
55
|
+
if (result !== 2n) { throw result }
|
|
52
56
|
},
|
|
53
57
|
() => {
|
|
54
|
-
const result =
|
|
58
|
+
const result = log2(8n)
|
|
55
59
|
if (result !== 3n) { throw result }
|
|
56
60
|
},
|
|
57
61
|
() => {
|
|
58
|
-
const result =
|
|
59
|
-
if (result !==
|
|
62
|
+
const result = log2(15n)
|
|
63
|
+
if (result !== 3n) { throw result }
|
|
60
64
|
},
|
|
61
65
|
() => {
|
|
62
|
-
const result =
|
|
66
|
+
const result = log2(16n)
|
|
63
67
|
if (result !== 4n) { throw result }
|
|
64
|
-
},
|
|
65
|
-
() => {
|
|
66
|
-
const result = log2x(16n)
|
|
67
|
-
if (result !== 5n) { throw result }
|
|
68
68
|
}
|
|
69
69
|
]
|
|
70
70
|
}
|