Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
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.
I've inherited a web application that's been up and running for three years.One of the tables in the SQL Server 2000 database has a bunch of fields that were declared as FLOAT -- but I am a bit confused about this.If I read the MS documentation correctly, the FLOAT data type starts at 1, right? So what do I do if the value is 0.8725?And what's the trick to make Query Analyzer display something other than zero when I type & execute:PRINT (4/80)Please, if anyone knows of a good tutorial or some other kind of helpful information, I'd be pretty happy with a link.Thanks.
Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)
7020 Posts
Posted - 2006-01-19 : 17:14:38
Float can hold 0.8725 just fine.The result of 4/80 = 0 is correct because it is an integer operation.You should read about data types and cast/convert in SQL Server Books Online for a complete explanation of these issues.
select y = (4/80), x = convert(float,0.8725) y x ----------- ----------------------------------------------------- 0 0.87250000000000005(1 row(s) affected)
CODO ERGO SUM
binggeli
Starting Member
20 Posts
Posted - 2006-01-19 : 17:24:08
Thanks for pointing me somewhere.However, why does "z" not produce something other than zero:
select y = (4/80), x = convert(float,0.8725), z = convert(float,(4/8)) y x z --- --------------------- ------- 0 0.87250000000000005 0.0
Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)
7020 Posts
Posted - 2006-01-19 : 17:30:53
The result of 4/8 = 0 because it is an integer operation.You should read about data types and cast/convert in SQL Server Books Online for a complete explanation of these issues.CODO ERGO SUM