javascript - JS Power of Issue -
i have been given calculation in excel, have replicate in js, cannot life of me figure out.
the calculation in excel 70*3^0.75
. result 159.565493987
, rounded 160.
in js have tried following
math.pow(70 * 3, .75); // 55.16510778290732 math.pow(70, .75) * 3; // 72.60136477480762 70*.75*3; // 157.5
console.log(70 * math.pow(3, .75)) // or console.log(70 * 3 ** .75)
in javascript, languages, exponentiation evaluates before multiplication. see order of operations.
note: exponentiation operator **
added in ecmascript 2016 standard, if want use portably, consider transpiler babel script.
Comments
Post a Comment