News Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

PHP 10.0 Blog:
Making $$$ with PHP
April 02, 2007 @ 08:26:00

In a brieft post to the PHP 10.0 Blog today, Stas looks at a topic several PHPers out there have had to struggle with in their math-centric applications - how floats/doubles are handled in PHP.

Just wanted to write about the topic discussed elsewhere - how one could do money calculations with PHP? PHP has no BCD type and no arbitrary precision float type either. And for money calculations is it important to have it very precise - accountants can not allow even single penny to slip by (remember the plot of the Office Space movie?)

He basically says that the precision that PHP alone offers just isn't enough for some kinds of functionality. He also offers his own kind of solution proposal - switching the values back to (arbitrary-precision) integers and making all calculations in hundredth or thousandths of a cent.

Not that, according to Ron in the comments, there is in fact a BCMath extension already built for PHP.

0 comments voice your opinion now!
floating point double bcmath extension floating point double bcmath extension


blog comments powered by Disqus

Similar Posts

Jim Plush's Blog: PHP Meet Mr. FireBug - PHP Debugging for Web 2.0

Derick Rethans: Understanding Valgrind errors (1)

Mike Lively's Blog: 81.4 is evil

Kristina Chodorow's Blog: Writing a PHP Extension (Four Part Series)

Ilia Alshanetsky's Blog: MySQL Binaries and cURL/http extensions in PHP


Community Events

Don't see your event here?
Let us know!


version install language example release extension api unittest voicesoftheelephpant opinion podcast framework library series introduction interview xdebug laravel php7 community

All content copyright, 2015 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework