php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #46232 Retrieved Floating Point Numbers From Float Column in MSSQL Appeares Different
Submitted: 2008-10-05 07:04 UTC Modified: 2008-10-05 10:19 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: butterfly110Pro at yahoo dot com Assigned:
Status: Not a bug Package: MSSQL related
PHP Version: 5.2.6 OS: Windows 2003 Server R2
Private report: No CVE-ID: None
 [2008-10-05 07:04 UTC] butterfly110Pro at yahoo dot com
Description:
------------
Salam,
When I Retrieving A Data From SQL Server With a Column that its Column Type in SQL Server is Float, I See That Two Type of Numbers Shows,
1. Integer Or Floating Numbers With its Real Writing Style (e.g. 
1200001, 1.200001)
1. Integer (This is What Happened For Me!) Numbers With Scientific Writing Style (e.g. 1200000 appeares 1.2E+6, 1400000 appeares 1.4E+6)
Fantastic Top That is This Appearance Diferrences Only Happens for (12 With More Than 5 Zeros, and 14 With More than 5 Zeros, I Try This For 1199999 and 1200001 But The Happen Didn't Happen!)

Reproduce code:
---------------
Select * From ATable

Expected result:
----------------
array(
 0 => array(
  FirstFloatColumn => 1199999,
  SecondFloatColumn => 1200000,
  ThirdFloatColumn => 1200001,

  FourthFloatColumn => 1399999,
  FifthFloatColumn => 1400000,
  SixthFloatColumn => 1400001,

  SeventhfFloatColumn => 1100000,
  EightthFloatColumn => 1300000,
  NinethFloatColumn => 1500000,
  TenthFloatColumn => 1600000,

  EleventhFloatColumn => 11999999,
  TwelvethFloatColumn => 12000000,
  ThirteenthFloatColumn => 12000001,

  FourteenthFloatColumn => 13999999,
  FifteenthFloatColumn => 14000000,
  SixteenthFloatColumn => 14000001,

 )
)

Actual result:
--------------
array(
 0 => array(
  FirstFloatColumn => 1199999,
  SecondFloatColumn => 1.2E+6,
  ThirdFloatColumn => 1200001,

  FourthFloatColumn => 1399999,
  FifthFloatColumn => 1.4E+6,
  SixthFloatColumn => 1400001,

  SeventhfFloatColumn => 1100000,
  EightthFloatColumn => 1300000,
  NinethFloatColumn => 1500000,
  TenthFloatColumn => 1600000,

  EleventhFloatColumn => 11999999,
  TwelvethFloatColumn => 1.2E+7,
  ThirteenthFloatColumn => 12000001,

  FourteenthFloatColumn => 13999999,
  FifteenthFloatColumn => 1.4E+7,
  SixteenthFloatColumn => 14000001,

 )
)

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-10-05 10:19 UTC] johannes@php.net
Floating point values have a limited precision. Hence a value might 
not have the same string representation after any processing. That also
includes writing a floating point value in your script and directly 
printing it without any mathematical operations.

If you would like to know more about "floats" and what IEEE
754 is, read this:
http://docs.sun.com/source/806-3568/ncg_goldberg.html
 
Thank you for your interest in PHP.

.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 09:01:28 2024 UTC