File tree Expand file tree Collapse file tree 3 files changed +161
-7
lines changed Expand file tree Collapse file tree 3 files changed +161
-7
lines changed Original file line number Diff line number Diff line change @@ -15,7 +15,11 @@ export function accuratePow64(x: f64, y: f64): f64 {
15
15
// or/and 10 ** -5 != 1e-5 anymore. For avoid this behaviour we are forcing exponent
16
16
// to fractional form and compensate this afterwards.
17
17
if ( isFinite ( y ) && Math . abs ( y ) >= 2 && Math . trunc ( y ) == y ) {
18
- return Math . pow ( x , y - 0.5 ) * Math . pow ( x , 0.5 ) ;
18
+ if ( y < 0 ) {
19
+ return Math . pow ( x , y + 0.5 ) / Math . pow ( x , 0.5 ) ;
20
+ } else {
21
+ return Math . pow ( x , y - 0.5 ) * Math . pow ( x , 0.5 ) ;
22
+ }
19
23
}
20
24
}
21
25
return Math . pow ( x , y ) ;
Original file line number Diff line number Diff line change 59314
59314
unreachable
59315
59315
end
59316
59316
f64.const 10
59317
+ f64.const -308
59318
+ call $~lib/math/NativeMath.pow
59319
+ f64.const 1e-308
59320
+ f64.eq
59321
+ i32.eqz
59322
+ if
59323
+ i32.const 0
59324
+ i32.const 32
59325
+ i32.const 4137
59326
+ i32.const 1
59327
+ call $~lib/builtins/abort
59328
+ unreachable
59329
+ end
59330
+ f64.const 10
59331
+ f64.const -323
59332
+ call $~lib/math/NativeMath.pow
59333
+ f64.const 1e-323
59334
+ f64.eq
59335
+ i32.eqz
59336
+ if
59337
+ i32.const 0
59338
+ i32.const 32
59339
+ i32.const 4138
59340
+ i32.const 1
59341
+ call $~lib/builtins/abort
59342
+ unreachable
59343
+ end
59344
+ f64.const 10
59317
59345
f64.const 208
59318
59346
call $~lib/math/NativeMath.pow
59319
59347
f64.const 1.e+208
59322
59350
if
59323
59351
i32.const 0
59324
59352
i32.const 32
59325
- i32.const 4137
59353
+ i32.const 4139
59354
+ i32.const 1
59355
+ call $~lib/builtins/abort
59356
+ unreachable
59357
+ end
59358
+ f64.const 10
59359
+ f64.const 64
59360
+ call $~lib/math/NativeMath.pow
59361
+ f64.const 1.e+64
59362
+ f64.eq
59363
+ i32.eqz
59364
+ if
59365
+ i32.const 0
59366
+ i32.const 32
59367
+ i32.const 4140
59368
+ i32.const 1
59369
+ call $~lib/builtins/abort
59370
+ unreachable
59371
+ end
59372
+ f64.const 10
59373
+ f64.const -64
59374
+ call $~lib/math/NativeMath.pow
59375
+ f64.const 1e-64
59376
+ f64.eq
59377
+ i32.eqz
59378
+ if
59379
+ i32.const 0
59380
+ i32.const 32
59381
+ i32.const 4141
59382
+ i32.const 1
59383
+ call $~lib/builtins/abort
59384
+ unreachable
59385
+ end
59386
+ f64.const 10
59387
+ f64.const 53
59388
+ call $~lib/math/NativeMath.pow
59389
+ f64.const 1.e+53
59390
+ f64.eq
59391
+ i32.eqz
59392
+ if
59393
+ i32.const 0
59394
+ i32.const 32
59395
+ i32.const 4142
59396
+ i32.const 1
59397
+ call $~lib/builtins/abort
59398
+ unreachable
59399
+ end
59400
+ f64.const 10
59401
+ f64.const -53
59402
+ call $~lib/math/NativeMath.pow
59403
+ f64.const 1e-53
59404
+ f64.eq
59405
+ i32.eqz
59406
+ if
59407
+ i32.const 0
59408
+ i32.const 32
59409
+ i32.const 4143
59410
+ i32.const 1
59411
+ call $~lib/builtins/abort
59412
+ unreachable
59413
+ end
59414
+ f64.const 10
59415
+ f64.const 0
59416
+ call $~lib/math/NativeMath.pow
59417
+ f64.const 1
59418
+ f64.eq
59419
+ i32.eqz
59420
+ if
59421
+ i32.const 0
59422
+ i32.const 32
59423
+ i32.const 4144
59424
+ i32.const 1
59425
+ call $~lib/builtins/abort
59426
+ unreachable
59427
+ end
59428
+ f64.const 10
59429
+ f64.const 5
59430
+ call $~lib/math/NativeMath.pow
59431
+ f64.const 1e5
59432
+ f64.eq
59433
+ i32.eqz
59434
+ if
59435
+ i32.const 0
59436
+ i32.const 32
59437
+ i32.const 4145
59326
59438
i32.const 1
59327
59439
call $~lib/builtins/abort
59328
59440
unreachable
59336
59448
if
59337
59449
i32.const 0
59338
59450
i32.const 32
59339
- i32.const 4138
59451
+ i32.const 4146
59452
+ i32.const 1
59453
+ call $~lib/builtins/abort
59454
+ unreachable
59455
+ end
59456
+ f64.const 10
59457
+ f64.const 3
59458
+ call $~lib/math/NativeMath.pow
59459
+ f64.const 1e3
59460
+ f64.eq
59461
+ i32.eqz
59462
+ if
59463
+ i32.const 0
59464
+ i32.const 32
59465
+ i32.const 4147
59466
+ i32.const 1
59467
+ call $~lib/builtins/abort
59468
+ unreachable
59469
+ end
59470
+ f64.const 10
59471
+ f64.const -3
59472
+ call $~lib/math/NativeMath.pow
59473
+ f64.const 0.001
59474
+ f64.eq
59475
+ i32.eqz
59476
+ if
59477
+ i32.const 0
59478
+ i32.const 32
59479
+ i32.const 4148
59340
59480
i32.const 1
59341
59481
call $~lib/builtins/abort
59342
59482
unreachable
59350
59490
if
59351
59491
i32.const 0
59352
59492
i32.const 32
59353
- i32.const 4139
59493
+ i32.const 4149
59354
59494
i32.const 1
59355
59495
call $~lib/builtins/abort
59356
59496
unreachable
59364
59504
if
59365
59505
i32.const 0
59366
59506
i32.const 32
59367
- i32.const 4140
59507
+ i32.const 4150
59368
59508
i32.const 1
59369
59509
call $~lib/builtins/abort
59370
59510
unreachable
Original file line number Diff line number Diff line change @@ -4133,8 +4133,18 @@ assert(0.0 ** 0 == 1.0);
4133
4133
assert ( 1.0 ** 1 == 1.0 ) ;
4134
4134
4135
4135
// Special cases for test constant fold correctness
4136
- assert ( 10.0 ** 308 == 1e308 ) ;
4137
- assert ( 10.0 ** 208 == 1e208 ) ;
4136
+ assert ( 10.0 ** + 308 == 1e+308 ) ;
4137
+ assert ( 10.0 ** - 308 == 1e-308 ) ;
4138
+ assert ( 10.0 ** - 323 == 1e-323 ) ;
4139
+ assert ( 10.0 ** + 208 == 1e+208 ) ;
4140
+ assert ( 10.0 ** + 64 == 1e+64 ) ;
4141
+ assert ( 10.0 ** - 64 == 1e-64 ) ;
4142
+ assert ( 10.0 ** + 53 == 1e+53 ) ;
4143
+ assert ( 10.0 ** - 53 == 1e-53 ) ;
4144
+ assert ( 10.0 ** 0 == 1e+0 ) ;
4145
+ assert ( 10.0 ** + 5 == 1e+5 ) ;
4138
4146
assert ( 10.0 ** - 5 == 1e-5 ) ;
4147
+ assert ( 10.0 ** + 3 == 1e+3 ) ;
4148
+ assert ( 10.0 ** - 3 == 1e-3 ) ;
4139
4149
assert ( f32 ( 10 ) ** 38 == f32 ( 1e38 ) ) ;
4140
4150
assert ( f32 ( 10 ) ** - 5 == f32 ( 1e-5 ) ) ;
You can’t perform that action at this time.
0 commit comments