Today, when reading the data of your project team, there is a table in the SQL Server database that stores site information, with latitude (latitude)
And longpolling (longitude). The data type is float. We all know that SQL float (8 bytes) and real (4 bytes, = float (24)
All types indicate the approximate values of the data. I think if the program code uses latitude and
The longpolling size is compared, so it will definitely make an inaccurate judgment.
So I checked the code immediately. Indeed, there was such a judgment of >=and <=. what's more hateful is that all the points of these sites must be displayed in bingmap.
I want to take an approximate value to show an incorrect point. This is what everyone does not want.
Okay, go to DBA. As the DBA explains, we only need to ensure that the number of decimal points in the stored data is all the same, here is the last 6, and then in the code
You can also retain only the six digits after the decimal point, which also allows a small error in Map Display. Naturally, it makes sense.
However, he later asked me what type the latitude and longpolling parameters in the Code are used to represent them. I think of them as double, and there are two points.
The distance between them. This is a terrible design! The float type of the database is taken out and assigned to the double type. There will be several more digits behind it, and its own values also have
The difference is also used to calculate the sphere distance, which means the accuracy is compromised. And double type computing efficiency is very low.
A better correction method is:
1. Change the LAT/lon type in the database to int type. That is, multiply the original float value by 1e6.
2. The data type of the Code is also changed to int. Divide the data type by 1e6!
Conclusion
1. Try to use int for database and code types, especially for numerical operations.
2. The data retrieved from the database should be kept in its nature as much as possible and converted only when it is actually used, that is, only one approximate operation is performed!