function _invoice_round in Invoice 7
Same name and namespace in other branches
- 6 invoice_helpers.inc \_invoice_round()
Helper function to get a rounded value
Read the comments on http://www.php.net/round why the standard PHP round() function doesn't work right.
For example with PHP round(38.675, 2) gives 38.67, but that must be 38.68
Parameters
mixed $value:
integer $precision:
Return value
float
4 calls to _invoice_round()
- invoice_load in ./
invoice.module - Implements hook_load()
- invoice_settings in ./
invoice.module - Invoice settings
- _invoice_get_invoice_totals in ./
invoice_helpers.inc - Helper function to calculate invoice totals
- _invoice_round_and_format_money in ./
invoice_helpers.inc - Returns a rounded and formatted number according to the locale set on the invoice settings page
File
- ./
invoice_helpers.inc, line 501 - Invoice module
Code
function _invoice_round($value, $precision = 0) {
$rounded_value = round(round($value * pow(10, $precision + 1), 0), -1) / pow(10, $precision + 1);
return $rounded_value;
}