Reputation: 2137
I am attempting to use Entity Framework and have a contact database that has Longitude and Latitude data from Google Maps.
The guide says that this should be stored as float.
I have created my POCO entity which includes Longitude
as a float
and Latitude
as a float
.
I have just noticed that in the database, these both come up as real
.
There is still a lot of work to be done before I can get any data back from Google, I am very far away from testing and I was just wondering if anyone can tell me if this is going to be a problem later on?
Upvotes: 3
Views: 3755
Reputation: 42510
This link:
http://msdn.microsoft.com/en-us/library/aa258876(v=sql.80).aspx
explains that, in SQL Server, real
is a synonym for float(24)
, using 4 bytes of data. In .NET a Single precision floating point number also uses 4 bytes, so these are pretty much equivalent:
http://msdn.microsoft.com/en-us/library/47zceaw7(v=vs.71).aspx
Upvotes: 2
Reputation: 1502716
Nope, that should be fine. Note that you may not get the exact same value back as you received from Google Maps, as that would have been expressed in decimal-formatted text. However, this is effectively a physical quantity, and thus more appropriate as a float/double/real/(whatever binary floating point type you like) than as a decimal. (Decimals are more appropriate for man-made quantities - particularly currency.)
If you look at the documentation for float
and real
you'll see that real
is effectively float(24)
- a 32-bit floating binary point type, just like float
in C#.
EDIT: As noted in comments, if you want more than the significant 7-8 digits of accuracy provided by float
, then you probably want double
instead in C#, which would mean float(53)
in SQL Server.
Upvotes: 6