固定性的对数
有可能使对数坚固吗? 我已经尝试找到但没有结果。 有什么解决方案可以使对数的坚固性u Guy?感谢您的帮助。
Is possible to caculate Logarithm in Solidity?
I have try to find but have no result.
Have any solution to caculate Logarithm in Solidity u guy? Thank you for your help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以尝试此库: https:// github。 com/abdk-consulting/abdk-libraries-solidity/blob/master/ABDKMathQuad.sol
Also,
You can try this library: https://github.com/abdk-consulting/abdk-libraries-solidity/blob/master/ABDKMathQuad.sol
Also, here is a list Math libraries for solidity, so maybe you can find something there.
您可以使用OpenZeppelin的
Math
库。https://docs.openzeppelin.com/contracts/contracts/5.x/ API/UTILS#数学
You can use
Math
library from openzeppelin.https://docs.openzeppelin.com/contracts/5.x/api/utils#Math
对于基本2对数:
对于基本10对数:
最后,对于基本n对数:
显然,此方法仅计算对数的整数部分。为了计算小数零件,我们必须扩展此解决方案。
For base 2 logarithm:
For base 10 logarithm:
And finally for base N logarithm:
Obviously this method calculates only integer part of logarithm. For calculating decimal parts, we must expand this solution.