0

I have a python script which returns 4678.5.

import math

x = 10000
a = 51878.09485
b = 149921.5759
c = -892138.3676

y = a * math.log2(b + x) + c
print(y)

I try to make the equivalent in JavaScript with:

let x = 10000
const a = 51878.09485
const b = 149921.5759
const c = -892138.3676

console.log(a * Math.log((b + x), 2) + c)

But it returns -270512.26978388603, I am not sure why?

  • `Math.log((b + x), 2)` is the same thing as `Math.log(b + x)`. Please read the documentation: [Using Math.log() with a different base](//developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Math/log#using_math.log_with_a_different_base). – Sebastian Simon Jan 19 '23 at 23:11

0 Answers0