Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Weird Float datatype problem

Status
Not open for further replies.

cervin

Programmer
Joined
May 1, 2003
Messages
1
Location
US
I have an SQL table that has a field that is of type Float. I have a ColdFusion application that reads and writes data to this table. The problem is if I put a value of say 2.1 in the ColdFusion form and submit it, then I go into the SQL table it shows me a value of 2.1 . But if I read this value out of the table in a ColdFusion page, it will show that the value is 2.099999999999998. Has anyone ever seen this? Does anyone know how I can fix this? Thanks in advanced.
 
Thats the joy of floats.

You may want to consider using numeric and define the number of decimal places.
 
Float and Real are approximate data types. Values cannot be represented precisely. That is why fluteplr recommended using Numeric (Decimal is equivalent) which is a fixed decimal data type and allows exact precision and scale declaration.

If you want to get the best answer for your question read faq183-874 and faq183-3179.
Terry L. Broadbent - DBA
SQL Server Page:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top