NYCPHP Meetup

NYPHP.org

[nycphp-talk] Unfriendly Float Handling

Michael Sims jellicle at gmail.com
Fri Mar 31 19:15:49 EST 2006


On Friday 31 March 2006 19:03, csnyder wrote:

> You definitely need to have a bag of tricks when you start dealing
> with monetary values (or other floats) in php. I felt exactly the same
> frustration the first time I crossed over from content management into
> commerce: four years of writing php code and I had never used
> number_format().
>
> Are there any good articles or tipsheets out there on working with
> money in php? If not, maybe there should be a Financial Phundamentals
> to help get other developers up to speed on the best practices for
> being arbitrarily precise.

Banks just handle monetary values to 4 or 6 decimal places.  If you 
manipulate values as "49.9500", it doesn't matter what you do to it, it 
will come out correct to the cent.

Michael Sims



More information about the talk mailing list