Re: PHP 4.0 Bug #6220 Updated: floor((0.7+0.1)*10) wrong
| From: | rockojfonzo at gmx dot net | Date: | Fri, 18 Aug 2000 11:32:47 +0000 |
| Subject: | Re: PHP 4.0 Bug #6220 Updated: floor((0.7+0.1)*10) wrong | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-29388@lists.php.net to get a copy of this message | ||
> ID: 6220
> Updated by: hholzgra
> Reported By: rockojfonzo@gmx.net
> Status: Closed
> Bug Type: Misbehaving function
> Assigned To:
> Comments:
>
> (and it's the same in C)
>
> this is related to binary float
> representation in microprocessors
>
> 7 and .1 are periodic fractions
> in binary system so you get minimal
> rounding errors
>
> so (0.7+0.1)*10) will result in something
> almost 8.0 but with a minimal positive or negative
> offset
>
> this usualy dosn't matter as rounding will be
> applied but it does matter for floor() as in this
> case the result is a very little less than 8
>
> conclusion: if you need the precisision than use bc
I´m sorry, what do you mean by "bc"?
--
Regards
Ron
Sent through GMX FreeMail - http://www.gmx.net