php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #23316 Loss of precision in float data when SQL Server is queried
Submitted: 2003-04-23 10:06 UTC Modified: 2003-05-20 18:42 UTC
From: hammer88 at hotmail dot com Assigned:
Status: Not a bug Package: MSSQL related
PHP Version: 4.3.2-RC OS: Windows 2000
Private report: No CVE-ID: None
 [2003-04-23 10:06 UTC] hammer88 at hotmail dot com
I created a query and tested in SQL Server Query Analyzer.  The query returns a number that is stored as 1.0947 as data type money to 8 digits. But when I run this query from PHP 

$dbTradeRow=mssql_fetch_object($trades_result) 

to retrieve the data and check that column, it returns only 1.09 and i loose the last two digits. Can somebody please help me out?

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-04-23 16:20 UTC] hammer88 at hotmail dot com
Replaced the php.exe & php4ts.dll files and verified the new version with phpinfo().  But problem still persisted.  Is this because php utilizes the local computer's currency settings?  Which I assume default for Windows is two decimal places?  That wouldn't be cool to have to change that default just for this instance... ideas?
 [2003-04-24 03:26 UTC] sniper@php.net
try it?

 [2003-04-30 06:14 UTC] sniper@php.net
Did changing the currency settings affect this or not?

 [2003-04-30 19:39 UTC] hammer88 at hotmail dot com
I did not try modifying the locale format.  My solution was just modifying the data type in SQL Server so it was a decimal instead of money.  All is well.
 [2003-05-20 18:21 UTC] fmk@php.net
updating php.exe and php4ts.dll is not enough. all the mssql functions are located in php_mssql.dll.
 [2003-05-20 18:42 UTC] fmk@php.net
MSSQL server will return 2 digits after the decimal point for money and small money solumns.

You can use the convert() function to increase this to 4 digits.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Apr 24 18:01:28 2024 UTC