note 17598 deleted from function.round by jimw
| From: | jimw@php.net | Date: | Wed, 02 Jan 2002 12:13:52 +0000 |
| Subject: | note 17598 deleted from function.round by jimw | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-24255@lists.php.net to get a copy of this message | ||
I'm currently writing a financial app in PHP which needs 100% precision.. however, a really
accurate (and version independant, see above) rounding function was missing, so I quickly wrote this
one which does the job perfectly. Thought I'll share it with you.
function bcround ($number, $decimals)
{
return(bcadd (bcadd ($number,"0.".str_repeat("0",$decimals)."5",
$decimals+1), 0, $decimals));
}
Enjoy and feel free to use it (fully at your own risk ;-).
- Felix Schwarz, Innovative