Re: math problem
| From: | Jason Wong | Date: | Mon, 14 Apr 2003 07:17:50 +0000 |
| Subject: | Re: math problem | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-143723@lists.php.net to get a copy of this message | ||
On Monday 14 April 2003 05:00, John W. Holmes wrote:
> Probably a floating point error problem. If you store 5000.00 into a
> variable, since it's a floating point number, it's perfectly acceptable
> to store 4999.99999999 into the field (with the appropriate amount of
> significant digits). So if you turned right around and compared that to
> an integer 5000, it's not going to be equal.
>
> You could probably solve your problem by casting $LoanAllowance to an
> integer (you're not going to lend cents, are you?) and then do the
> compariston.
>
> $LoanAllowance = (int)$LoanAllowance
Or better still, use the BCMath functions if they are available on your
version of PHP.
--
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
------------------------------------------
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
------------------------------------------
/*
Save the whales. Collect the whole set.
*/