News Feed
Sections




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

Mike Lively's Blog:
81.4 is evil
January 04, 2007 @ 08:39:00

On his blog, Mike Lively has a little reminder for developers out there about working with floating point numbers in your applications, specifically their accuracy.

I know many of you all know pretty well that floating point precision and computers don't play nicely with each other. [...] I was working with a piece of code today at the office that was throwing an error saying two values weren't zeroing out when they clearly should have been.

In his code he shows the simple bit that he was using to evaluate if the result of subtraction would come to a certain value. In the comments, others share similar experiences and one even recommends another option to make things a bit more accurate - the bcmath library.

0 comments voice your opinion now!
floating point accuracy zero value floating point accuracy zero value


blog comments powered by Disqus

Similar Posts

Felix Geisendorfer's Blog: False == 0, or not?

Stijn Leenknegt's Blog: [PHP6] function-return-array idea!

Internet Super Hero Blog: PHP: mysqli_stmt_get_result()

Mike Bernat's Blog: CakePHP - Changing the Default Value of a Date-Time Input

SitePoint PHP Blog: Which reference sites do you trust?


Community Events





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


version symfony artisanfiles list podcast introduction opinion tool conference library series community language laravel release voicesoftheelephpant framework interview composer security

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