@@ -213,13 +213,15 @@ function pow( x, y ) {
213213 if ( isnan ( x ) || isnan ( y ) ) {
214214 return NaN ;
215215 }
216+ console . log ( 'inside\n' ) ;
216217 // Split `y` into high and low words:
217218 toWords . assign ( y , WORDS , 1 , 0 ) ;
218219 hy = WORDS [ 0 ] ;
219220 ly = WORDS [ 1 ] ;
220-
221+ console . log ( 'hy: %d^ ly: %d\n' , hy , ly ) ;
221222 // Special cases `y`...
222223 if ( ly === 0 ) {
224+ console . log ( 'inside ly==0\n' ) ;
223225 if ( y === 0.0 ) {
224226 return 1.0 ;
225227 }
@@ -246,36 +248,46 @@ function pow( x, y ) {
246248 return x * x ;
247249 }
248250 if ( isInfinite ( y ) ) {
251+ console . log ( 'inside is-infinite\n' ) ;
249252 return yIsInfinite ( x , y ) ;
250253 }
251254 }
252255 // Split `x` into high and low words:
253256 toWords . assign ( x , WORDS , 1 , 0 ) ;
254257 hx = WORDS [ 0 ] ;
255258 lx = WORDS [ 1 ] ;
259+ console . log ( 'hx: %d^ lx: %d\n' , hx , lx ) ;
256260
257261 // Special cases `x`...
258262 if ( lx === 0 ) {
263+ console . log ( 'lx==0\n' ) ;
259264 if ( hx === 0 ) {
265+ console . log ( 'hx==0\n' ) ;
260266 return xIsZero ( x , y ) ;
261267 }
262268 if ( x === 1.0 ) {
269+ console . log ( '2\n' ) ;
263270 return 1.0 ;
264271 }
265272 if (
266273 x === - 1.0 &&
267274 isOdd ( y )
268275 ) {
276+ console . log ( '3\n' ) ;
269277 return - 1.0 ;
270278 }
271279 if ( isInfinite ( x ) ) {
280+ console . log ( '4\n' ) ;
272281 if ( x === NINF ) {
282+ console . log ( '5\n' ) ;
273283 // `pow( 1/x, -y )`
274284 return pow ( - 0.0 , - y ) ;
275285 }
276286 if ( y < 0.0 ) {
287+ console . log ( '6\n' ) ;
277288 return 0.0 ;
278289 }
290+ console . log ( '7\n' ) ;
279291 return PINF ;
280292 }
281293 }
@@ -287,55 +299,69 @@ function pow( x, y ) {
287299 return ( x - x ) / ( x - x ) ;
288300 }
289301 ax = abs ( x ) ;
290-
302+ console . log ( 'ax: %d\n' , ax ) ;
291303 // Remove the sign bits (i.e., get absolute values):
292304 ahx = ( hx & ABS_MASK ) | 0 ; // asm type annotation
293305 ahy = ( hy & ABS_MASK ) | 0 ; // asm type annotation
294-
306+ console . log ( 'ahx: %d^ ahy: %d\n' , ahx , ahy ) ;
295307 // Extract the sign bits:
296308 sx = ( hx >>> HIGH_NUM_NONSIGN_BITS ) | 0 ; // asm type annotation
297309 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 ) ) ;
299312 // Determine the sign of the result...
300313 if ( sx && isOdd ( y ) ) {
314+ console . log ( '8\n' ) ;
301315 sx = - 1.0 ;
302316 } else {
317+ console . log ( '9\n' ) ;
303318 sx = 1.0 ;
304319 }
305320 // Case 1: `|y|` is huge...
306321
307322 // |y| > 2^31
308323 if ( ahy > HIGH_BIASED_EXP_31 ) {
324+ console . log ( '10\n' ) ;
309325 // `|y| > 2^64`, then must over- or underflow...
310326 if ( ahy > HIGH_BIASED_EXP_64 ) {
327+ console . log ( '11\n' ) ;
311328 return yIsHuge ( x , y ) ;
312329 }
313330 // Over- or underflow if `x` is not close to unity...
314331
315332 if ( ahx < HIGH_MAX_NEAR_UNITY ) {
333+ console . log ( '12\n' ) ;
316334 // y < 0
317335 if ( sy === 1 ) {
336+ console . log ( '13\n' ) ;
318337 // Signal overflow...
319338 return sx * HUGE * HUGE ;
320339 }
340+ console . log ( '14\n' ) ;
321341 // Signal underflow...
322342 return sx * TINY * TINY ;
323343 }
324344 if ( ahx > HIGH_BIASED_EXP_0 ) {
345+ console . log ( '15\n' ) ;
325346 // y > 0
326347 if ( sy === 0 ) {
348+ console . log ( '16\n' ) ;
327349 // Signal overflow...
328350 return sx * HUGE * HUGE ;
329351 }
352+ console . log ( '17\n' ) ;
330353 // Signal underflow...
331354 return sx * TINY * TINY ;
332355 }
356+ console . log ( '18\n' ) ;
333357 // 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`.
334358 t = logx ( LOG_WORKSPACE , ax ) ;
335359 }
336360 // Case 2: `|y|` is not huge...
337361 else {
362+ console . log ( '19\n' ) ;
338363 t = log2ax ( LOG_WORKSPACE , ax , ahx ) ;
364+ console . log ( 'ax: %d, ahx: %d\n' , ax , ahx ) ;
339365 }
340366 // Split `y` into `y1 + y2` and compute `(y1+y2) * (t1+t2)`...
341367 y1 = setLowWord ( y , 0 ) ;
@@ -350,31 +376,40 @@ function pow( x, y ) {
350376
351377 // z >= 1024
352378 if ( j >= HIGH_BIASED_EXP_10 ) {
379+ console . log ( '20\n' ) ;
353380 // z > 1024
354381 if ( ( ( j - HIGH_BIASED_EXP_10 ) | i ) !== 0 ) {
382+ console . log ( '21\n' ) ;
355383 // Signal overflow...
356384 return sx * HUGE * HUGE ;
357385 }
386+ console . log ( '22\n' ) ;
358387 if ( ( lp + OVT ) > ( z - hp ) ) {
388+ console . log ( '23\n' ) ;
359389 // Signal overflow...
360390 return sx * HUGE * HUGE ;
361391 }
362392 }
363393 // z <= -1075
364394 else if ( ( j & ABS_MASK ) >= HIGH_1075 ) {
395+ console . log ( '24\n' ) ;
365396 // z < -1075
366397 if ( ( ( j - HIGH_NEG_1075 ) | i ) !== 0 ) {
398+ console . log ( '25\n' ) ;
367399 // Signal underflow...
368400 return sx * TINY * TINY ;
369401 }
370402 if ( lp <= ( z - hp ) ) {
403+ console . log ( '26\n' ) ;
371404 // Signal underflow...
372405 return sx * TINY * TINY ;
373406 }
374407 }
408+ console . log ( '27\n' ) ;
375409 // Compute `2^(hp+lp)`...
376410 z = pow2 ( j , hp , lp ) ;
377-
411+ console . log ( '%d^%d' , z , sx ) ;
412+ console . log ( '28\n' ) ;
378413 return sx * z ;
379414}
380415
0 commit comments