问题标签 [bcmath]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
php - 用于将 Hex 转换为 Dec 的 BCMath 代码 - 问题 - 代码中的错误?
我对尝试将十六进制值转换为十进制值的代码有一些问题。无论是小整数还是大整数,有时,该函数都会返回我转换为十进制的十六进制,尾随为 8 个 ceros。例如:它应该返回 72500 并返回 72500.00000000 它是随机的,我认为代码“是正确的”。
好一个:
错误一:
程序
php - 为什么扩展在命令行上可用,但在 nginx 提供的脚本中不可用?
我在 docker 容器中运行 nginx/php-fpm 服务器,并添加了一个扩展
bcmath 函数在命令行中可用,但在脚本中不可用
即这有效:
但这失败了
当交付为
结果(在浏览器中)=
为什么命令行可以看到扩展名,而脚本却看不到?非常感谢任何帮助。谢谢。
php - 在 Debian 上安装 php7.1-bcmath
我正在尝试在Debian GNU/Linux 9 (stretch)上为 PHP 7.1 安装 bcmath:
apt install php7.1-bcmath
抛出一个未找到的错误。
我已经尝试过apt-get update --fix-missing
没有成功。
它似乎特定于 php7.1,因为当我尝试其他版本时,一切似乎都很好并要求确认:
ubuntu - 无法安装php7.1-bcmath ubuntu 14.04
我有一个安装了 ubuntu 14.04、php7.1-fpm 的 VPS 并运行了很长时间。我正在尝试安装 php7.1-bcmath。它一直在说
E: 找不到包 php7.1-bcmath
E: 通过正则表达式 'php7.1-bcmath' 找不到任何包
我已经尝试添加
添加 apt 存储库 ppa:ondrej/php
它说:
按 [ENTER] 继续或 ctrl-c 取消添加它 gpg: keyring /tmp/tmph26v3afu/secring.gpg' created
gpg:密钥环 /tmp/tmph26v3afu/pubring.gpg' 创建
gpg:从 hkp 服务器 keyserver.ubuntu.com 请求密钥 E5267A6C
gpg:/tmp/tmph26v3afu/trustdb。
gpg:创建了信任数据库
gpg: key E5267A6C:public key "Launchpad PPA for Ondřej Surý" 导入 gpg: 处理总数: 1
gpg: 导入: 1 (RSA: 1) OK
我也做过:
sudo apt-get 更新
但即使在这之后它说
E: 通过正则表达式 'php7.1-bcmath' 找不到任何包
任何帮助都是有帮助的。
php - undefined function bandwidthThrottle\tokenBucket\util\bcsub() 当bcsub安装在服务器上所有php版本时
我在 Ubutu 服务器上有一个项目。我不断收到以下错误
我们使用的包是 bandwidth-throttle/token-bucket,我们使用的是 2.0
我已确保在服务器上的每个 php 版本中都安装了 bcmath
我跑了以下;
当我运行“php -r”print_r(get_loaded_extensions());“”时,我得到以下信息,所以我知道它在那里,但我的项目无论如何都会抛出错误
我还跑了 print_r(get_loaded_extensions()); 在网络服务器上下文中(如:通过浏览器获取它,而不是在 shell 上)
有什么建议吗?
- 编辑
我现在发现设置的php版本是7.2,我知道php.ini在哪里
docker - Docker:您的系统中缺少请求的 PHP 扩展 bcmath
安装 bcmath 时出现以下错误
我尝试使用以下命令仍然是同样的错误
php - PHP BC 数学库忽略舍入规则
我正在使用bcdiv
PHP 中的函数来计算一些东西,但结果与应有的不同。这是示例代码:
第一次的结果var_dump
对我来说很奇怪,因为它应该是10而不是9。
其他BCMath函数 的结果相同:
我的应用程序中有很多浮点计算,现在我不知道如何正确处理它们,正常的数学计算有浮点问题,但从bc 数学计算不是我应该使用的最好的东西。
所以,这是我的问题:
- 当您考虑常规数学舍入规则时,考虑到 BCMath 结果是错误的,我该如何处理浮点计算?
- 您(其他 PHP 程序员)如何计算浮点数?在我的应用程序中无法将它们转换为整数。
- 你觉得php-decimal怎么样?
php - 无法弄清楚为什么我得到 App Engine flex“未捕获的错误:调用未定义的函数 Google\Protobuf\Internal\bccomp()”
我正在尝试在 App Engine flex 环境中实现 Google 的 Text-To-Speech API,但出现此错误:
“PHP 消息:PHP 致命错误:未捕获的错误:调用 /app/web/vendor/google/protobuf/src/Google/Protobuf/Internal/Message.php:941 中的未定义函数 Google\Protobuf\Internal\bccomp()”
一旦我通过在我的 composer.json 中要求 BCmath() 解决了这个问题
然后重新安装 /vendor 后,我无法摆脱错误消息。我试图通过运行安装 BCmath 扩展
但它说扩展已经安装。我也运行这个 php -i | grep -i bcmath 并收到此消息
/etc/php/7.2/cli/conf.d/20-bcmath.ini, bcmath BCMath 支持 => 启用 bcmath.scale => 0 => 0
bccomp() 的测试
我应该得到'-1'。看起来该功能有效。
我什至尝试在 php.ini 中启用 BCmath 扩展
我将 .ini 文件放在与 /vendor 和 index.php 相同的目录中。尽管如此,在部署应用程序后
我仍然收到致命错误。
php - 如何在 PHP 中将小浮点数与未知的小数位数相乘而不会因为科学记数法而变为零?
我试图在 PHP 中乘以一些小数字,但 bcmul 返回零,因为浮点值正在变成科学记数法。
我尝试sprintf('%.32f',$value)
在小的浮点值上使用,但由于小数位数未知,因此舍入错误,然后乘法时会导致舍入错误。
另外,我不能用strpos('e',$value)
它来找出它是否是科学记数法数字,因为即使我将它转换为字符串也找不到它(string)$value
这是一些示例代码:
php - Is there any particular reason that PHP doesn't do bcadd() whenever + is used?
Whenever I'm dealing with numbers in PHP which represent money, I'm forced to use bcadd()
and the other functions in that "family", instead of simply using the nice symbols such as +
, -
, /
and *
.
The reason is something about "floats" being inaccurate for some reason. I've many times tried to understand why exactly this is, but I can't make any sense of it.
It would be much nicer to use the symbols instead of the BC Math
functions.
Why aren't the floats just accurate instead? Or made into "numerics" if "floats" by their nature are inaccurate?
It's not a problem anymore because I know about this, but for most of my life when I'm coded PHP, I had no clue even about the existence of those functions, let alone the need to use them.