Reputation: 9839
I'm working with Javascript and noticing it return some weird values.
12194 / (10^8)
121945000000 / (10^8)
Am I doing something wrong here or is this an issue with Javascript numbers?
Upvotes: 2
Views: 125
Reputation: 8751
^
is the XOR operator in javascript. Refer to Bitwise XOR
You should use either Math.pow() or **
console.log(12194 / Math.pow(10, 8))
console.log(121945000000 / Math.pow(10, 8))
console.log(12194 / (10 ** 8))
console.log(121945000000 / (10 ** 8))
Upvotes: 4
Reputation: 79
You can't use the ^ in JavaScript for equations.
Instead, you can use 12194 / Math.pow(10, 8)
https://www.w3schools.com/jsref/jsref_pow.asp
Upvotes: 2