Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Using CONVERT with FLOAT data really bugs me...

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2001-09-27 : 09:17:57
Joey writes "Why do floating point numbers get rounded and truncated when a CONVERT is used as shown below, and, more importantly, is there any way to get a CONVERT to accurately display the floating point number in the way it is stored (without rounding and truncating it)? Thanks!

/* Code: */

SET NOCOUNT ON
DECLARE @myfloat FLOAT
SET @myfloat = 1.123456789012345
SELECT @myfloat AS original_float
SELECT CONVERT(VARCHAR(30),@myfloat) AS converted_float

/* Results:

original_float
-----------------------------------------------------
1.123456789012345

converted_float
------------------------------
1.12346

*/"
   

- Advertisement -