php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #25279 real numbers get twisted
Submitted: 2003-08-27 14:04 UTC Modified: 2003-08-28 08:33 UTC
From: t dot noest at noestnet dot nl Assigned:
Status: Not a bug Package: MSSQL related
PHP Version: 4.3.3 OS: winnt
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
5 + 14 = ?
Subscribe to this entry?

 
 [2003-08-27 14:04 UTC] 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!



Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-08-27 15:02 UTC] 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-28 08:33 UTC] t dot noest at noestnet dot nl
Oepsh! You are right. I forgot. Sorry, and thanks

Thomas
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Jul 21 23:01:29 2024 UTC