十进制数的和与差给出 PHP 中的周期数
在我的 PHP 代码中,我有一个变量对应于从 MySQL 数据库获取的某些值的总和与差。这是代码:
<?php echo $verifica = (($valoreEntrate + $valoreInCassa) - ($valoreUscite + $valorePagamentiInSospeso + $valoreDaLasciareInCassa + $valoreDaPortareACasa)); ?>
这是通过 echo 获得的所有涉及变量的值:
$valoreEntrate = 3837.67
$valoreInCassa = 612.10
$valoreUscite = 97.81
$valorePagamentiInSospeso = 0
$valoreDaLasciareInCassa = 617.80
$valoreDaPortareACasa = 3734.22
$verifica 的值是:
$verifica = -0.0599999999995
而不是像我预期的 -0.6... 谁能解释为什么这个值? 太感谢了!!! 再见...
In my PHP code I have a variable that corresponds to the sum and difference of some values obtained from a MySQL database. This is the code:
<?php echo $verifica = (($valoreEntrate + $valoreInCassa) - ($valoreUscite + $valorePagamentiInSospeso + $valoreDaLasciareInCassa + $valoreDaPortareACasa)); ?>
Here is values of all variables involved obtained with echo:
$valoreEntrate = 3837.67
$valoreInCassa = 612.10
$valoreUscite = 97.81
$valorePagamentiInSospeso = 0
$valoreDaLasciareInCassa = 617.80
$valoreDaPortareACasa = 3734.22
The value of $verifica is:
$verifica = -0.0599999999995
Instead of -0.6 like I expected...
Can anyone explain why this value?
Thank you so much!!!
Bye...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是因为它们是
float
类型,并且浮点数不存储为精确的数字。有关详细信息,请参阅 PHP 关于 float 的条目。This is because they are
float
types, and floats are not stored as exact numbers. See PHP's entry on float for further information.