Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Gusarich committed Mar 21, 2024
1 parent dc741ae commit 5e914a5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2991,7 +2991,7 @@ return b.end_cell().begin_parse();",
}
int result = 0;
while (num >= base) {
num = num / base;
num /= base;
result += 1;
}
return result;",
Expand Down Expand Up @@ -6846,7 +6846,7 @@ return b.end_cell().begin_parse();",
}
int result = 0;
while (num >= base) {
num = num / base;
num /= base;
result += 1;
}
return result;",
Expand Down Expand Up @@ -10701,7 +10701,7 @@ return b.end_cell().begin_parse();",
}
int result = 0;
while (num >= base) {
num = num / base;
num /= base;
result += 1;
}
return result;",
Expand Down
21 changes: 6 additions & 15 deletions src/test/feature-math.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -360,23 +360,14 @@ describe('feature-math', () => {

const maxint = 2n ** 256n - 1n;

function bigIntLogBase(num: bigint, base: bigint) {
let result = 0n;
while (num >= base) {
num = num / base;
result += 1n;
}
return result;
}

for (let num = maxint - 100n; num <= maxint; num++) {
expect(await contract.getLog2(num)).toBe(255n);
}

for (let num = maxint - 10n; num <= maxint; num++) {
for (let base = 2n; base <= 10; base++) {
expect(await contract.getLog(num, base)).toBe(
bigIntLogBase(num, base)
for (let base = 2; base <= 10; base++) {
expect(await contract.getLog(num, BigInt(base))).toBe(
BigInt(num.toString(base).length - 1)
);
}
}
Expand All @@ -389,9 +380,9 @@ describe('feature-math', () => {
}

for (let num = maxint / 2n - 5n; num <= maxint / 2n + 5n; num++) {
for (let base = 2n; base <= 10; base++) {
expect(await contract.getLog(num, base)).toBe(
bigIntLogBase(num, base)
for (let base = 2; base <= 10; base++) {
expect(await contract.getLog(num, BigInt(base))).toBe(
BigInt(num.toString(base).length - 1)
);
}
}
Expand Down

0 comments on commit 5e914a5

Please sign in to comment.