Bug #42770 MySQL ODBC is rounding Float(M,D) data
Submitted: 11 Feb 2009 17:20 Modified: 12 Feb 2009 20:25
Reporter: Adrian Chapela Cordeiro Email Updates:
Status: Won't fix Impact on me:
None 
Category:Connector / ODBC Severity:S2 (Serious)
Version:3.51.19,3.51.27 and 5.1.5 OS:Windows
Assigned to: Jess Balint CPU Architecture:Any
Tags: ODBC mysql float

[11 Feb 2009 17:20] Adrian Chapela Cordeiro
Description:
I have defined a table with two floats. These floats are defined as "float(9,6)". I have inserted this number 37.637535. When I try to retrieve this data, I am receiving on my web server "37.63754".

I am using IIS 5.0, Windows 2000 with last updates, MySQL ODBC above versions and ADODB.Recordset.

How to repeat:
Create a ODBC connection to your server named as "test_connection".

Create a table:

CREATE TABLE test_table (latitud float(9,6) NOT NULL default '0', longitud float(9,6) NOT NULL default '0') ENGINE=InnoDB

Use this code on your own IIS WebServer:

<%
Option Explicit

Dim rs
Set rs = Server.CreateObject ("ADODB.RecordSet")
rs.Open "SELECT latitud, longitud FROM test_database.test_table limit 2", "DSN=test_connection", 1

response.write "<table border=1>"
response.write "<tr><td>Float</td><td>Float</td></tr>"
do while not rs.eof 
	response.write "<tr><td>" & rs.fields("latitud") & "</td><td>" & rs.fields("latitud") & "</td></tr>"
	rs.movenext
loop	
response.write "</table>"
%>
[11 Feb 2009 17:26] Adrian Chapela Cordeiro
Server version: 5.1.30 and 5.1.31 (I have tested these versions)
Server is sending the values with total number of decimals. The round is doing on the client side.
[12 Feb 2009 20:25] Tonci Grgin
We've been thinking over this for few days now with no luck. Best I can say is that vbs has no typing because everything is essentially a variant. Variant *might* be limited when it comes to floating point but we don't know...

To work around problems like this, please use CDbl function:
  CDbl(rs.Field(0))

Won't fix as I don't see what to fix.
[12 Feb 2009 21:15] Jess Balint
Dim v2 As System.Single
         v2 = 37.637535
         MsgBox(v2)

prints 37.63754