Re: floored by floor()
| From: | Thijs Lensselink | Date: | Thu, 14 Oct 2010 06:50:38 +0000 |
| Subject: | Re: floored by floor() | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-308689@lists.php.net to get a copy of this message | ||
On 10/14/2010 07:48 AM, Mattias Thorslund wrote:
Hi List, I'm having a problem with the behavior of the floor() function: echo floor(327.03 * 100)."\n"; //prints "32702" and not "32703"!! Sanity check: var_dump(327.03 * 100); //prints "float(32703)" as expected Any ideas why this happens, and how to work around it? Thanks, MattiasRead the floating point precision part http://nl2.php.net/float Use round() before you use floor() to get the expected result.