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)
 Floating number

Author  Topic 

iminore
Posting Yak Master

141 Posts

Posted - 2005-08-17 : 08:42:30
I'm reading a recordset from a SQL Server procedure. One of the columns is type float but when I get it back into my ASP code I'm losing precision of the last few digits.

An example is 1125899906863598.0 which becomes
1.1258999068636E+15

Using FormatNumber doesn't help - the last few digits have somehow been lost.

Using CDbl gives 1125899906863600

Any ideas?

Kristen
Test

22859 Posts

Posted - 2005-08-17 : 09:02:01
Perhaps CAST it as a DECIMAL so SQL ships it in that format, rather than a Float?

Kristen
Go to Top of Page

iminore
Posting Yak Master

141 Posts

Posted - 2005-08-17 : 09:17:21
Just tried that - same result.
I'm setting the variable in ASP as double but it seems determined to drop the last two digits.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-08-17 : 09:18:57
What happens if you use decimal or float type variable in ASP?

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

iminore
Posting Yak Master

141 Posts

Posted - 2005-08-17 : 09:27:39
No such types in ASP vbscript.
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2005-08-17 : 09:38:36
CAST it as a varchar(50) and then convert to number in ASP?

If that works then its the worst Hack I've ever come up with!

Kristen
Go to Top of Page

iminore
Posting Yak Master

141 Posts

Posted - 2005-08-17 : 09:41:35
Tried that, but thanks for the effort.
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2005-08-17 : 09:49:52
perhaps you are exceeding the precision of Double?

http://msdn.microsoft.com/library/en-us/script56/html/vbsDataType.asp?frame=true

looks like it ought to be 15 digits though, not 14. Still one less than you need ...

Maybe the ADO driver is droping some precision - presumably yours is up-to-date?

Kristen
Go to Top of Page

iminore
Posting Yak Master

141 Posts

Posted - 2005-08-17 : 11:47:39
Think I may have cracked it.
Defined column as bigint (instead of float) and casting now preserves lower digits.
Go to Top of Page
   

- Advertisement -