bcpow 和 pow 有什么区别?
有人可以向我解释一下我是否应该使用 bcpow() 而不是 pow() 以及为什么?
据我了解,并非所有 php 安装都启用了 bcmath。因此,如果我编写一个开源项目,并且希望拥有尽可能少的依赖项/要求,我宁愿在代码中使用 pow() 。
但是使用 pow() 相对于 bcpow() 有何缺点?
Can someone explain to me if I should use bcpow() instead of pow() and why?
I understand that not all installations of php have bcmath enabled. So if I write an open source project, and want to have as few dependencies/requirements as possible, I would rather use pow() in my code.
But what are the downsides to using pow() over bcpow()?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
bcpow()
是BCMath 任意精度数学 库。引用它的手册的介绍:
On the other hand, [**`pow()`**][3] is limited to [floats][4], which have a limited size *(quoting)* :
Generally, you'll work with `pow()` and other float-based functions *(which are probably faster, and are always enabled)* ; but, if you need to handle very big number, you'll have to work with `bcpow()`.
bcpow()
is a function of the BCMath Arbitrary Precision Mathematics library.Quoting the introduction of it's manual :
On the other hand, [**`pow()`**][3] is limited to [floats][4], which have a limited size *(quoting)* :
Generally, you'll work with `pow()` and other float-based functions *(which are probably faster, and are always enabled)* ; but, if you need to handle very big number, you'll have to work with `bcpow()`.
根据 手册 的
bc*
功能是pow()
仅限于其运行的系统上支持的最大数字表示形式。According to the manual the
bc*
functions arepow()
is limited to the maximum supported numeric representation on the system it runs on.bcpow
用于任意精度值。作为第三个参数,您可以指定逗号后的位数。bcpow
is used for arbitrary precision values. As a third parameter you can specify a number of digits after coma.