@@ -213,13 +213,15 @@ function pow( x, y ) {
213
213
if ( isnan ( x ) || isnan ( y ) ) {
214
214
return NaN ;
215
215
}
216
+ console . log ( 'inside\n' ) ;
216
217
// Split `y` into high and low words:
217
218
toWords . assign ( y , WORDS , 1 , 0 ) ;
218
219
hy = WORDS [ 0 ] ;
219
220
ly = WORDS [ 1 ] ;
220
-
221
+ console . log ( 'hy: %d^ ly: %d\n' , hy , ly ) ;
221
222
// Special cases `y`...
222
223
if ( ly === 0 ) {
224
+ console . log ( 'inside ly==0\n' ) ;
223
225
if ( y === 0.0 ) {
224
226
return 1.0 ;
225
227
}
@@ -246,36 +248,46 @@ function pow( x, y ) {
246
248
return x * x ;
247
249
}
248
250
if ( isInfinite ( y ) ) {
251
+ console . log ( 'inside is-infinite\n' ) ;
249
252
return yIsInfinite ( x , y ) ;
250
253
}
251
254
}
252
255
// Split `x` into high and low words:
253
256
toWords . assign ( x , WORDS , 1 , 0 ) ;
254
257
hx = WORDS [ 0 ] ;
255
258
lx = WORDS [ 1 ] ;
259
+ console . log ( 'hx: %d^ lx: %d\n' , hx , lx ) ;
256
260
257
261
// Special cases `x`...
258
262
if ( lx === 0 ) {
263
+ console . log ( 'lx==0\n' ) ;
259
264
if ( hx === 0 ) {
265
+ console . log ( 'hx==0\n' ) ;
260
266
return xIsZero ( x , y ) ;
261
267
}
262
268
if ( x === 1.0 ) {
269
+ console . log ( '2\n' ) ;
263
270
return 1.0 ;
264
271
}
265
272
if (
266
273
x === - 1.0 &&
267
274
isOdd ( y )
268
275
) {
276
+ console . log ( '3\n' ) ;
269
277
return - 1.0 ;
270
278
}
271
279
if ( isInfinite ( x ) ) {
280
+ console . log ( '4\n' ) ;
272
281
if ( x === NINF ) {
282
+ console . log ( '5\n' ) ;
273
283
// `pow( 1/x, -y )`
274
284
return pow ( - 0.0 , - y ) ;
275
285
}
276
286
if ( y < 0.0 ) {
287
+ console . log ( '6\n' ) ;
277
288
return 0.0 ;
278
289
}
290
+ console . log ( '7\n' ) ;
279
291
return PINF ;
280
292
}
281
293
}
@@ -287,55 +299,69 @@ function pow( x, y ) {
287
299
return ( x - x ) / ( x - x ) ;
288
300
}
289
301
ax = abs ( x ) ;
290
-
302
+ console . log ( 'ax: %d\n' , ax ) ;
291
303
// Remove the sign bits (i.e., get absolute values):
292
304
ahx = ( hx & ABS_MASK ) | 0 ; // asm type annotation
293
305
ahy = ( hy & ABS_MASK ) | 0 ; // asm type annotation
294
-
306
+ console . log ( 'ahx: %d^ ahy: %d\n' , ahx , ahy ) ;
295
307
// Extract the sign bits:
296
308
sx = ( hx >>> HIGH_NUM_NONSIGN_BITS ) | 0 ; // asm type annotation
297
309
sy = ( hy >>> HIGH_NUM_NONSIGN_BITS ) | 0 ; // asm type annotation
298
-
310
+ console . log ( 'sx: %d^ sy: %d\n' , sx , sy ) ;
311
+ console . log ( 'check_if_odd: %d\n' , isOdd ( y ) ) ;
299
312
// Determine the sign of the result...
300
313
if ( sx && isOdd ( y ) ) {
314
+ console . log ( '8\n' ) ;
301
315
sx = - 1.0 ;
302
316
} else {
317
+ console . log ( '9\n' ) ;
303
318
sx = 1.0 ;
304
319
}
305
320
// Case 1: `|y|` is huge...
306
321
307
322
// |y| > 2^31
308
323
if ( ahy > HIGH_BIASED_EXP_31 ) {
324
+ console . log ( '10\n' ) ;
309
325
// `|y| > 2^64`, then must over- or underflow...
310
326
if ( ahy > HIGH_BIASED_EXP_64 ) {
327
+ console . log ( '11\n' ) ;
311
328
return yIsHuge ( x , y ) ;
312
329
}
313
330
// Over- or underflow if `x` is not close to unity...
314
331
315
332
if ( ahx < HIGH_MAX_NEAR_UNITY ) {
333
+ console . log ( '12\n' ) ;
316
334
// y < 0
317
335
if ( sy === 1 ) {
336
+ console . log ( '13\n' ) ;
318
337
// Signal overflow...
319
338
return sx * HUGE * HUGE ;
320
339
}
340
+ console . log ( '14\n' ) ;
321
341
// Signal underflow...
322
342
return sx * TINY * TINY ;
323
343
}
324
344
if ( ahx > HIGH_BIASED_EXP_0 ) {
345
+ console . log ( '15\n' ) ;
325
346
// y > 0
326
347
if ( sy === 0 ) {
348
+ console . log ( '16\n' ) ;
327
349
// Signal overflow...
328
350
return sx * HUGE * HUGE ;
329
351
}
352
+ console . log ( '17\n' ) ;
330
353
// Signal underflow...
331
354
return sx * TINY * TINY ;
332
355
}
356
+ console . log ( '18\n' ) ;
333
357
// At this point, `|1-x|` is tiny (`<= 2^-20`). Suffice to compute `log(x)` by `x - x^2/2 + x^3/3 - x^4/4`.
334
358
t = logx ( LOG_WORKSPACE , ax ) ;
335
359
}
336
360
// Case 2: `|y|` is not huge...
337
361
else {
362
+ console . log ( '19\n' ) ;
338
363
t = log2ax ( LOG_WORKSPACE , ax , ahx ) ;
364
+ console . log ( 'ax: %d, ahx: %d\n' , ax , ahx ) ;
339
365
}
340
366
// Split `y` into `y1 + y2` and compute `(y1+y2) * (t1+t2)`...
341
367
y1 = setLowWord ( y , 0 ) ;
@@ -350,31 +376,40 @@ function pow( x, y ) {
350
376
351
377
// z >= 1024
352
378
if ( j >= HIGH_BIASED_EXP_10 ) {
379
+ console . log ( '20\n' ) ;
353
380
// z > 1024
354
381
if ( ( ( j - HIGH_BIASED_EXP_10 ) | i ) !== 0 ) {
382
+ console . log ( '21\n' ) ;
355
383
// Signal overflow...
356
384
return sx * HUGE * HUGE ;
357
385
}
386
+ console . log ( '22\n' ) ;
358
387
if ( ( lp + OVT ) > ( z - hp ) ) {
388
+ console . log ( '23\n' ) ;
359
389
// Signal overflow...
360
390
return sx * HUGE * HUGE ;
361
391
}
362
392
}
363
393
// z <= -1075
364
394
else if ( ( j & ABS_MASK ) >= HIGH_1075 ) {
395
+ console . log ( '24\n' ) ;
365
396
// z < -1075
366
397
if ( ( ( j - HIGH_NEG_1075 ) | i ) !== 0 ) {
398
+ console . log ( '25\n' ) ;
367
399
// Signal underflow...
368
400
return sx * TINY * TINY ;
369
401
}
370
402
if ( lp <= ( z - hp ) ) {
403
+ console . log ( '26\n' ) ;
371
404
// Signal underflow...
372
405
return sx * TINY * TINY ;
373
406
}
374
407
}
408
+ console . log ( '27\n' ) ;
375
409
// Compute `2^(hp+lp)`...
376
410
z = pow2 ( j , hp , lp ) ;
377
-
411
+ console . log ( '%d^%d' , z , sx ) ;
412
+ console . log ( '28\n' ) ;
378
413
return sx * z ;
379
414
}
380
415
0 commit comments