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做了一个简单的划分。然后我在运行 apache 的 windows 机器和运行 apache 的 linux 机器上测试结果。
WINDOWS: 1/15 returns 0.066666666666667 LINUX: 1/15 returns 0.0666666666667
有什么建议为什么会发生这种情况?是php、apache还是操作系统?
通常,PHP 浮点数的大小取决于平台,因此如果您想要可移植代码,则不应做任何假设。
但是,您看到的差异也可能是由配置设置的差异引起的。浮点值的打印值precision取决于设置。
precision
有关的:
php 配置。浮点精度设置。小数位数选项。