File tree 2 files changed +9
-8
lines changed
2 files changed +9
-8
lines changed Original file line number Diff line number Diff line change 1
- // The range of valid numbers is -2^53 to 2^53 - 1
2
- export const MAX_NUMBER = Math . pow ( 2 , 53 ) - 1 ;
3
- export const MIN_NUMBER = - Math . pow ( 2 , 53 ) ;
1
+ export const MAX_NUMBER = Number . MAX_SAFE_INTEGER ;
2
+ export const MIN_NUMBER = Number . MIN_SAFE_INTEGER ;
4
3
export const MIN_BASE = 2 ;
5
4
export const MAX_BASE = Math . floor ( Math . sqrt ( MAX_NUMBER + 1 ) ) | 0 ;
Original file line number Diff line number Diff line change @@ -13,9 +13,9 @@ function macro ( t , number ) {
13
13
14
14
macro . title = ( providedTitle , number ) => `toNumber: ${ number } ` ;
15
15
16
- function throws ( t , string ) {
17
- const integer = ZZ . from ( string ) ;
18
- t . is ( string , integer . toString ( ) ) ;
16
+ function throws ( t , string , plus ) {
17
+ const integer = ZZ . from ( string ) . addn ( plus ) ;
18
+ t . is ( string , integer . subn ( plus ) . toString ( ) ) ;
19
19
t . throws ( ( ) => integer . toNumber ( ) , { instanceOf : ValueError } ) ;
20
20
}
21
21
@@ -34,12 +34,14 @@ once(1);
34
34
once ( - 1 ) ;
35
35
once ( MIN_NUMBER ) ;
36
36
once ( MAX_NUMBER ) ;
37
+ once ( MIN_NUMBER + 1 ) ;
38
+ once ( MAX_NUMBER - 1 ) ;
37
39
38
40
while ( tested . size < N ) {
39
41
const number = randint ( MIN_NUMBER , MAX_NUMBER + 1 ) ;
40
42
if ( tested . has ( number ) ) continue ;
41
43
once ( number ) ;
42
44
}
43
45
44
- test ( throws , '9007199254740992' ) ;
45
- test ( throws , '-9007199254740993' ) ;
46
+ test ( throws , MAX_NUMBER . toString ( ) , + 1 ) ;
47
+ test ( throws , MIN_NUMBER . toString ( ) , - 1 ) ;
You can’t perform that action at this time.
0 commit comments