Skip to content

Commit 85b7d83

Browse files
🐛 fix(mul): Respect @aureooms/js-integer-big-endian limits on base.
1 parent 724ed9c commit 85b7d83

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

src/_limits.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
export const MAX_NUMBER = Math.pow(2,53) - 1 ;
33
export const MIN_NUMBER = -Math.pow(2,53) ;
44
export const MIN_BASE = 2 ;
5-
export const MAX_BASE = Math.ceil(Math.sqrt(MAX_NUMBER+1)) | 0;
5+
export const MAX_BASE = Math.floor(Math.sqrt(MAX_NUMBER+1)) | 0;

test/src/integer/bugs/mul.js

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import test from 'ava' ;
2+
3+
import { parse , stringify , mul } from '../../../../src' ;
4+
5+
test ( 'mul handles overflow' , t => {
6+
const X = '81129639699425365877808850315535' ;
7+
const expected = '6582018437758576371414942707515558118625242782831331069062336225'
8+
const x = parse( X ) ;
9+
const r = mul( x , x ) ;
10+
t.is( X , stringify( x ) ) ;
11+
t.is( expected , stringify( r ) ) ;
12+
} )

0 commit comments

Comments
 (0)