Skip to content

Commit

Permalink
fix(base-n): fix #308, remove unintentional int cast
Browse files Browse the repository at this point in the history
- use Math.floor() in BaseN.encode() to avoid casting intermediate
  values to 32 bit int range
  • Loading branch information
postspectacular committed Aug 24, 2021
1 parent f1bc0e3 commit 27a0d7e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion packages/base-n/src/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export class BaseN implements IBase {
let res = "";
while (x > 0) {
res = base[x % N] + res;
x = (x / N) | 0;
x = Math.floor(x / N);
}
return res;
}
Expand Down

0 comments on commit 27a0d7e

Please sign in to comment.