#25279 [Bgs]: real numbers get twisted

From: Date: Thu, 28 Aug 2003 13:33:17 +0000
Subject: #25279 [Bgs]: real numbers get twisted
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-46843@lists.php.net to get a copy of this message
ID: 25279 User updated by: t dot noest at noestnet dot nl Reported By: t dot noest at noestnet dot nl Status: Bogus Bug Type: MSSQL related Operating System: winnt PHP Version: 4.3.3 New Comment: Oepsh! You are right. I forgot. Sorry, and thanks Thomas Previous Comments: ------------------------------------------------------------------------ [2003-08-27 15:02:07] abies@php.net This is a known limitation of floating point numbers. This has nothing to do with either the database or PHP. If you want perfect accuracy, use a 'money' or 'numeric' field. ------------------------------------------------------------------------ [2003-08-27 14:04:54] t dot noest at noestnet dot nl Description: ------------ I just installed PHP4.3.3, the binary windows build, on my winnt machine. Something is going wrong with the real numbers I put in the MSSQL 7 database(fieldtype = "real"). I save for instance the number 7.02: "UPDATE Teksten SET Volgorde_nummer = 7.02 WHERE RecID = 220" MSSQLServer say's the value in the database is 7.02. When pulled back by PHP: "SELECT * FROM Teksten WHERE RecID = 220" $rs = mssql_query($SQL); $k = mssql_fetch_array($rs); echo $k['Volgorde_nummer']; give's me : 7.01999998093 And worse: "UPDATE Teksten SET Volgorde_nummer = 7.01 WHERE RecID = 220" Now MSSQLServer say's the value in the database is 7.0100002. echo $k['Volgorde_nummer']; give's me : 7.01000022888 I got the newest mssql.dll from the zip distribution. But it doesn't make any difference. I have had these problems with almost every new version of PHP I install! ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=25279&edit=1

« previous php.bugs (#46843) next »