Why is Math.pow() (sometimes) not equal to ** in JavaScript? Why is Math.pow() (sometimes) not equal to ** in JavaScript? google-chrome google-chrome

Why is Math.pow() (sometimes) not equal to ** in JavaScript?


99**99 is evaluated at compile time ("constant folding"), and the compiler's pow routine is different from the runtime one. When evaluating ** at run time, results are identical with Math.pow — no wonder since ** is actually compiled to a Math.pow call:

console.log(99**99);           // 3.697296376497268e+197a = 99, b = 99;console.log(a**b);             // 3.697296376497263e+197console.log(Math.pow(99, 99)); // 3.697296376497263e+197