Is it possible to get a natural log of a big-integer instance?

蓝咒 提交于 2019-12-25 16:54:28

问题


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?


回答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 × 1034.

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');
var integer = bigInt('5384932048329483948394829348923849').toString();
var ln_x = Math.log(10 + integer);


来源:https://stackoverflow.com/questions/29418957/is-it-possible-to-get-a-natural-log-of-a-big-integer-instance

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!