PHP中的负(负)零等于0?
发布时间:2020-12-13 13:07:56 所属栏目:PHP教程 来源:网络整理
导读:我有一个非常基本的 MySQL查询,它从数据库表中读取行,并将行值添加或减去定义为$total_balance的 PHP字符串. 例如; $statement_details_query = mysqli_query($con,"SELECT transaction_nominal_code,SUM(transaction_debit) as TotalDebit,SUM(transaction_
我有一个非常基本的
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) (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |