Subj : dividing NaN To : netscape.public.mozilla.jseng From : Jun Kim Date : Wed Nov 24 2004 10:11 am I'm trying to embed jsengine in non window platform. And I was testing division, and dividing non number, I was getting Infinity. So I looked at the code (spidermonkey), and I found this code. case JSOP_DIV: FETCH_NUMBER(cx, -1, d2); FETCH_NUMBER(cx, -2, d); sp--; if (d2 == 0) { #if defined(XP_WIN) || defined(XP_OS2) /* XXX MSVC miscompiles such that (NaN == 0) */ if (JSDOUBLE_IS_NaN(d2)) rval = DOUBLE_TO_JSVAL(rt->jsNaN); else #endif if (d == 0 || JSDOUBLE_IS_NaN(d)) rval = DOUBLE_TO_JSVAL(rt->jsNaN); else if ((JSDOUBLE_HI32(d) ^ JSDOUBLE_HI32(d2)) >> 31) rval = DOUBLE_TO_JSVAL(rt->jsNegativeInfinity); else rval = DOUBLE_TO_JSVAL(rt->jsPositiveInfinity); STORE_OPND(-1, rval); } else { d /= d2; STORE_NUMBER(cx, -1, d); } break; this code is in jsinterp.c doing the basic operation, I assume. this is the division part, and you can see that there's #if define statement. d is the numerator and d2 is the denominator. well, ECMA spec tells that dividing by NaN results NaN, and in non window platform, checking for d2 of NaN will not be compiled, which results in Infinity. Can anyone tell me why that part is blocked by the #if define statement? (I don't understand the comment right below.) .