File tree Expand file tree Collapse file tree 3 files changed +16
-4
lines changed Expand file tree Collapse file tree 3 files changed +16
-4
lines changed Original file line number Diff line number Diff line change @@ -79,7 +79,7 @@ import {} from "https://gitee.com/masx200/leetcode-test/raw/master/mod.ts";
79
79
```
80
80
81
81
``` ts
82
- import {} from " https://github. com/masx200/leetcode-test/raw /master/mod.ts" ;
82
+ import {} from " https://raw.githubusercontent. com/masx200/leetcode-test/master/mod.ts" ;
83
83
```
84
84
85
85
``` ts
@@ -93,7 +93,7 @@ import {} from "https://gitee.com/masx200/leetcode-test/raw/4.0.1/mod.ts";
93
93
```
94
94
95
95
``` ts
96
- import {} from " https://github. com/masx200/leetcode-test/raw /4.0.1/mod.ts" ;
96
+ import {} from " https://raw.githubusercontent. com/masx200/leetcode-test/4.0.1/mod.ts" ;
97
97
```
98
98
99
99
``` ts
Original file line number Diff line number Diff line change 1
- import { assertAlmostEquals } from "../deps.ts" ;
1
+ import { assert } from "../deps.ts" ;
2
2
import { pow_x_n } from "../mod.ts" ;
3
+ import { float64equals } from "../utils/float64equals.ts" ;
3
4
4
5
Deno . test ( "powx-n" , ( ) => {
5
6
const examples : {
6
7
input : Parameters < typeof pow_x_n > ;
7
8
output : ReturnType < typeof pow_x_n > ;
8
9
} [ ] = [
9
10
{ input : [ 2.0 , 10 ] , output : 1024.0 } ,
11
+ { input : [ 100 , 100 ] , output : 1e200 } ,
10
12
{ input : [ 2.1 , 3 ] , output : 9.261 } ,
11
13
{ input : [ 2.0 , - 2 ] , output : 0.25 } ,
12
14
{
@@ -37,6 +39,6 @@ Deno.test("powx-n", () => {
37
39
{ input : [ 0 , - Infinity ] , output : Infinity } ,
38
40
] ;
39
41
examples . forEach ( ( { input, output } ) => {
40
- assertAlmostEquals ( output , pow_x_n ( ...input ) ) ;
42
+ assert ( float64equals ( output , pow_x_n ( ...input ) ) ) ;
41
43
} ) ;
42
44
} ) ;
Original file line number Diff line number Diff line change
1
+ export function float64equals ( a : number , b : number ) : boolean {
2
+ // console.log(a, b);
3
+ if ( ! Number . isFinite ( a ) || ! Number . isFinite ( b ) ) {
4
+ return a === b ;
5
+ }
6
+ if ( b === 0 ) {
7
+ return a === b ;
8
+ }
9
+ return Math . abs ( ( a - b ) / b ) < 1e-14 ;
10
+ }
You can’t perform that action at this time.
0 commit comments