float和double数据类型有利于存储经度和长度? [英] float and double datatype is good to store lattitude and longtitude?
问题描述
我在服务器端存储经度和纬度(JAVA平台)。
为了存储这些值,我在服务器端使用了float和double数据类型。我知道float和double不是推荐的原始数据类型(不建议使用专业的货币),因为float和double有舍入精度问题。
就我而言,我只是比较服务器端存储的坐标(经度和纬度)。
问题1:
将坐标与数据类型(float或double)进行比较会在未来出现问题吗?
<问题2:
使用大数字是好的吗?或者用float或double来更安全?
请指导我。
这不是安全问题,它只是一个精确的问题。
我不会考虑花车,但是双打是我认为最理想的地方。
您只需要看看双精度最高的精度,看它是否符合常规经度/纬度值。我认为它已经足够了。
否则BigDecimal只是您问题的简单后门,如果您想要更高的精度,请使用它。
I am storing latitude and longitude at the server side (JAVA Platform).
To store those values , I am using float and double datatype at the server side. I came to know that float and double are not a recommended primitive datatypes (which is not recommended to use currencies in professional way), because float and double having rounding precision problem.
In my case , I am just comparing the stored coordinates ( lattitude and longtitude ) at the server side.
Question 1 :
Comparing the coordinates with the datatypes (float or double) will make any problem in future ?
Question 2 :
Using big decimal is good ? or Going with float or double is safer ?
Please guide me.
It's not a matter of safety, its just a matter of precision. I wouldn't consider floats, but doubles are what i think are ideal here. You just need to see what's the most precision you can get out of a double and see if it fits a regular longitude/latitude value. I think it's more then enough.
Else BigDecimal is just a simple backdoor to your problem, use it if you want more precision
这篇关于float和double数据类型有利于存储经度和长度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!