Re: Re: currency rounding issues

From: Date: Thu, 06 Jun 2002 03:46:19 +0000
Subject: Re: Re: currency rounding issues
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-100872@lists.php.net to get a copy of this message
As a side note, your final question does make sense - I was surprised (dunno why, but I was) to find there are things which cost less then 1c, some even less than 1/10 c, so... Bogdan Michael Davey wrote:
I have found that the best way to work with currencies is to avoid using any type of floating point math. If you multiply your start amount by 100, then perform your calculations as integers and then divide by 100 again at the end, it should work out OK... (Heh, at least it has worked for me when doing tax calcs and stuff - who know what you are doing?!?!?!?) Mikey "Paul Berg" <paul@spondo.com> wrote in message news:20020606010121.24069.qmail@pb1.pair.com...
Hi, I am putting together an app that involves the adding together of rounded numbers and displaying in a currency format. The round() function is causing errors of 1 cent to appear after addition. Does anyone know of any routines that might assist? Thanks in advance... Paul


« previous php.general (#100872) next »