[PHP-DEV] PHP 4.0 Bug #9411 Updated: Arithmetic error

2001-02-22 Thread lyric

ID: 9411
Updated by: lyric
Reported By: [EMAIL PROTECTED]
Old-Status: Closed
Status: Bogus
Old-Bug Type: *Regular Expressions
Bug Type: Math related
Assigned To: 
Comments:

This is nothing to do with PHP, its just part of the way computers store 
floating-point numbers. It stores an aproximation of 0.32, as close as it can get, but 
when you start multiplying it, the little difference between 0.32 and what it stored 
starts to get magnified.

BTW, 5.5511151231258E-17 is 0.55511151231258 which is *really* closed 
to 0.

If you want to output formatted numbers, you should either round it, or use printf()
http://www.php.net/manual/en/function.printf.php


Previous Comments:
---

[2001-02-22 16:05:47] [EMAIL PROTECTED]
This is normal floating point math behavior

---

[2001-02-22 15:45:55] [EMAIL PROTECTED]
Hi I am not sure if I have found a bug - what do you think...?

Consider this:

$var1 = -0.32 + (0.1*3.2)

This should give var1 the value 0, instead it gives

5.5511151231258E-17 

Interestingly if you increase -0.33 and 3.3 respectively it gives the correct answer. 
Werid!

Rob Burne

[EMAIL PROTECTED]


---



ATTENTION! Do NOT reply to this email!
To reply, use the web interface found at http://bugs.php.net/?id=9411edit=2


-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DEV] PHP 4.0 Bug #9411 Updated: Arithmetic error

2001-02-22 Thread Derick Rethans

Hi,

can't we make this a FAQ?
(if I get no response, it's in the FAQ in 60 mins :)

Derick

On 22 Feb 2001 [EMAIL PROTECTED] wrote:

 ID: 9411
 Updated by: lyric
 Reported By: [EMAIL PROTECTED]
 Old-Status: Closed
 Status: Bogus
 Old-Bug Type: *Regular Expressions
 Bug Type: Math related
 Assigned To:
 Comments:

 This is nothing to do with PHP, its just part of the way computers store 
floating-point numbers. It stores an aproximation of 0.32, as close as it can get, 
but when you start multiplying it, the little difference between 0.32 and what it 
stored starts to get magnified.

 BTW, 5.5511151231258E-17 is 0.55511151231258 which is *really* 
closed to 0.

 If you want to output formatted numbers, you should either round it, or use printf()
 http://www.php.net/manual/en/function.printf.php


 Previous Comments:
 ---

 [2001-02-22 16:05:47] [EMAIL PROTECTED]
 This is normal floating point math behavior

 ---

 [2001-02-22 15:45:55] [EMAIL PROTECTED]
 Hi I am not sure if I have found a bug - what do you think...?

 Consider this:

 $var1 = -0.32 + (0.1*3.2)

 This should give var1 the value 0, instead it gives

 5.5511151231258E-17

 Interestingly if you increase -0.33 and 3.3 respectively it gives the correct 
answer. Werid!

 Rob Burne

 [EMAIL PROTECTED]


 ---



 ATTENTION! Do NOT reply to this email!
 To reply, use the web interface found at http://bugs.php.net/?id=9411edit=2


 --
 PHP Development Mailing List http://www.php.net/
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]


Derick Rethans

-
PHP: Scripting the Web - www.php.net - [EMAIL PROTECTED]
 SRM: Site Resource Manager - www.vl-srm.net
-
JDI Media Solutions - www.jdimedia.nl - [EMAIL PROTECTED]
 Boulevard Heuvelink 102 - 6828 KT Arnhem - The Netherlands
-


-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]