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 {
1515 // or/and 10 ** -5 != 1e-5 anymore. For avoid this behaviour we are forcing exponent
1616 // to fractional form and compensate this afterwards.
1717 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+ }
1923 }
2024 }
2125 return Math . pow ( x , y ) ;
Original file line number Diff line number Diff line change 5931459314 unreachable
5931559315 end
5931659316 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
5931759345 f64.const 208
5931859346 call $~lib/math/NativeMath.pow
5931959347 f64.const 1.e+208
5932259350 if
5932359351 i32.const 0
5932459352 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
5932659438 i32.const 1
5932759439 call $~lib/builtins/abort
5932859440 unreachable
5933659448 if
5933759449 i32.const 0
5933859450 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
5934059480 i32.const 1
5934159481 call $~lib/builtins/abort
5934259482 unreachable
5935059490 if
5935159491 i32.const 0
5935259492 i32.const 32
59353- i32.const 4139
59493+ i32.const 4149
5935459494 i32.const 1
5935559495 call $~lib/builtins/abort
5935659496 unreachable
5936459504 if
5936559505 i32.const 0
5936659506 i32.const 32
59367- i32.const 4140
59507+ i32.const 4150
5936859508 i32.const 1
5936959509 call $~lib/builtins/abort
5937059510 unreachable
Original file line number Diff line number Diff line change @@ -4133,8 +4133,18 @@ assert(0.0 ** 0 == 1.0);
41334133assert ( 1.0 ** 1 == 1.0 ) ;
41344134
41354135// 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 ) ;
41384146assert ( 10.0 ** - 5 == 1e-5 ) ;
4147+ assert ( 10.0 ** + 3 == 1e+3 ) ;
4148+ assert ( 10.0 ** - 3 == 1e-3 ) ;
41394149assert ( f32 ( 10 ) ** 38 == f32 ( 1e38 ) ) ;
41404150assert ( f32 ( 10 ) ** - 5 == f32 ( 1e-5 ) ) ;
You can’t perform that action at this time.
0 commit comments