Re: Math weirdness with doubles...
| From: | Daniel Clark | Date: | Fri, 27 Feb 2004 22:16:16 +0000 |
| Subject: | Re: Math weirdness with doubles... | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-179033@lists.php.net to get a copy of this message | ||
Looks like the Doubles are not exactly zero. Must be some precision
points not displaying.
> Ok... It's Friday and maybe my brain is dead, but I'm having a weird
> problem with some basic math.
>
> Here's a little snippet of the code I'm working with:
>
> ---------------------------
> echo "<p>Current:$currentAmount:".gettype($currentAmount)." -
> Paid:$paidAmount:".gettype($paidAmount)."</p>";
>
> $currentAmount = $currentAmount-$paidAmount;
> echo "<p>Final Current: $currentAmount";
> -----------------
>
> Straightforward... Yeah?
>
> Here's a sample of the output:
> Current:97.6:double - Paid:97.6:double
> Final Current: 1.42108547152E-014
>
> Now if both $currentAmount and $paidAmount are doubles, subtracting them
> should yield a zero, shouldn't it?
>
> -- jon
>
> -------------------
> jon roig
> web developer
> email: jon@trafficdesigns.com
> phone: 888.230.7557
>
> ---
> Outgoing mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.593 / Virus Database: 376 - Release Date: 2/20/2004
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>