【发布时间】:2018-03-22 20:49:43
【问题描述】:
我试图计算一个整数和一个浮点数。听起来很简单吧?
但是当我执行以下代码时:
<?php
$decimals = 2;
$dec_point = ',';
$thousands_sep = '.';
$net_no = 851.12;
$net_no = number_format($net_no,$decimals,$dec_point,$thousands_sep);
$months = 13;
$tot_amount = $months * $net_no;
$tot_amount =
number_format($tot_amount,$decimals,$dec_point,$thousands_sep);
print $tot_amount;
结果我得到 11.063,00,但我希望得到 11.064,56 (13*851.12)。
这里出了什么问题?
【问题讨论】:
标签: floating-point integer calculator