Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Floating point and remote views
Message
 
 
To
21/07/2011 09:44:53
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows XP SP2
Database:
MS SQL Server
Miscellaneous
Thread ID:
01518756
Message ID:
01518761
Views:
58
Float type is not precise and better be avoided in SQL Server as well.

Do you really need very high precision? May be, say, 6 digits after . will be enough? If yes, then define your fields as decimal (20,6) in SQL Server (or take less depending on values you plan to hold).

Search MSDN T-SQL forum for the associated problems or check Brad Schulz blog

Quick search brings this thread
http://social.msdn.microsoft.com/Forums/en/transactsql/thread/17c90cbe-018e-4f47-b813-d20d69dcd264

but I think I read either Brad's or George Mastros blog on this topic also

http://blogs.lessthandot.com/index.php/DataMgmt/DBProgramming/do-not-use-the-float-data-type

and a controversial

http://blogs.msdn.com/b/qingsongyao/archive/2009/11/14/float-datatype-is-evil.aspx

>I am hoping some of the serious math wonks will take pity on an old man who still finds long division challenging.
>
>I have SQL database tables that make heavy use of floating point numbers.
>
>In my remote view, I am pulling half a dozen of those numbers. The remote view defines them as data type 'B' ( of which I have not previous experience)
>
>I need to multiply those number together, then put the result in a field I created as part of the remote view ( casting a 0 as float )
>
>But in the watch window these values all show up as N , even though the values can look like 140333030.002033021000
>And when I multiply them the result looks like a float, But when I try to save the value into a view column, I get a numeric data overflow.
>
>Trying to cast the numbers as B just gets them lopped off after about 4 decimals. ( I think this has something to do with 16bit vs 32 bit math, but since my brain runs on an i386sx chip, it is beyond me )
>
>I'm sure this problem is nothing new to anyone who has tried it and I found this
>
>http://fox.wikis.com/wc.dll?Wiki~VFPFloatingPointDataType
>
>on the wiki.
>
>But I am trying to wrap my brain around how to employ conversions ( and which of the functions to use ) in pulling, manipulating and hopefully saving the data.
>
>Really stuck on this one.
>
>TIA
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform