PHP中的负(负)零等于0?

前端之家收集整理的这篇文章主要介绍了PHP中的负(负)零等于0?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我有一个非常基本的 MySQL查询,它从数据库表中读取行,并将行值添加或减去定义为$total_balance的 PHP字符串.

例如;

$statement_details_query = MysqLi_query($con,"SELECT transaction_nominal_code,SUM(transaction_debit) as TotalDebit,SUM(transaction_credit) as TotalCredit FROM accounts_transaction GROUP BY transaction_nominal_code") or die(MysqL_error());

while($statement_details = MysqLi_fetch_array( $statement_details_query )) {

$balance = $statement_details['TotalCredit'] - $statement_details['TotalDebit'];

$total_balance = $total_balance + $balance;

}

echo number_format($total_balance,2,'.',',');

我的问题是,-0和0之间有什么区别?

PHP中,没有真正的区别:

浮动:

PHP > $negZ = -0.0;
PHP > $posZ = +0.0;
PHP > var_dump($negZ == $posZ,$negZ === $posZ);
bool(true)
bool(true)

诠释:

PHP > $negZ = -0;
PHP > $posZ = +0;
PHP > var_dump($negZ == $posZ,$negZ === $posZ);
bool(true)
bool(true)
原文链接:https://www.f2er.com/php/136424.html

猜你在找的PHP相关文章