Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
php 版本 5.4.33 php.ini: bcmath.scale = 0 (也试过 bcmath.scale = PHP_INI_ALL)
问题:
php5433 -r "echo bccomp(0.00000001, 0, 9);" 打印 0
php5433 -r "echo bccomp(1.00000001, 1, 9);" 打印 1
为什么?任何人都可以帮忙吗?
这是因为bccomp前 2 个参数是字符串。正如您在此处看到的,当它们是字符串时,它按预期工作。为什么是这样?我不确定,但它可能与为什么echo 0.00000001;输出 1.0E-8(科学记数法)而echo 1.00000001;输出 1.00000001(示例)有关
bccomp
echo 0.00000001;
echo 1.00000001;
bcmath.scale = 0仅在未提供时设置默认比例值bcscale
bcmath.scale = 0
bcscale
为所有未明确指定比例参数的 bc 数学函数的后续调用设置默认比例参数。