我需要在不四舍五入的情况下添加值(美元金额)。
例子:
添加的值来自$("input#lunchorder_item_price")
并输出我的 subTotal。
2.95 + 2.95 + 2.45 = 8.35但我得到2.95 + 2.95 + 2.45 = 8.36
当前代码:
function updateCartDisplayTotal() {
$("div#ordersummary").remove();
var subTotal = 0;
$("input#lunchorder_item_price").each(function() {
subTotal += parseFloat((this.value) + subTotal);
});
var orderSubtotal = subTotal.toFixed(2);
var taxAmount = parseFloat(orderSubtotal*.0685)/*.toFixed(2)*/;
var deliveryAmount = parseFloat(orderSubtotal*.10)/*.toFixed(2)*/;
var orderTotal = (parseFloat(orderSubtotal) + parseFloat(taxAmount) + parseFloat(deliveryAmount))/*.toFixed(2)*/;
var orderSummary = $("<div id=\"ordersummary\"><div>Subtotal: <strong>$"+ orderSubtotal +"</strong></div><div>Tax: <strong>$"+ taxAmount +"</strong></div><div>Delivery Fee: <strong>$"+ deliveryAmount +"</strong></div><div>Total: <strong>$"+ orderTotal +"</strong></div></div>");
$(orderSummary).insertAfter("ul#cart-items");
}
我的问题是我需要做些什么来防止这些四舍五入?任何帮助将不胜感激!