Re: Converting floats to ints with intval

From: Date: Thu, 06 May 2010 10:40:41 +0000
Subject: Re: Converting floats to ints with intval
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-304945@lists.php.net to get a copy of this message
Ashley Sheridan wrote:
It's part of the rounding problem you get with most languages out there. Why can't you compare the floating point values though? Currency should only have one decimal place anyway.
You can't compare floating point values because if you have, for example, a user-entered value of '37.12' and add that to '0.18' it won't necessarily be equal to '37.30'. Currency must have two decimal places, otherwise how would you represent five pounds and sixteen pence (£5.16) for example? -- Paul Waring http://www.pwaring.com

« previous php.general (#304945) next »