Is It Possible To Get A Natural Log Of A Big-integer Instance?
I am using big-integer for JavaScript. var bigInt = require('big-integer') I have a bigInt instance: var ratherLargeNumber = bigInt(2).pow(2048) Can I get a (natural) log of it?
Solution 1:
Say you have a big integer x = 5384932048329483948394829348923849
.
If you convert x to a decimal string and count the digits, you can then represent x by 0.5384932048329483948394829348923849
× 10.
You want to take the natural logarithm of x. Observe the following.
loge(x) = 34
loge(10
) + loge(0.5384932048329483948394829348923849
)
You can now use regular Number
computations and the regular Math.log
to perform the computation.
var bigInt = require('big-integer');
varinteger = bigInt('5384932048329483948394829348923849').toString();
var ln_x = Math.log(10 + integer);
Post a Comment for "Is It Possible To Get A Natural Log Of A Big-integer Instance?"