[英]How to compare a double value to a decimal from database and if they are alike, then return true
Example: 例:
Database latitude value: 33.3360705 数据库纬度值:33.3360705
location from android device latitude value: 33.33607 android设备纬度值的位置:33.33607
These are technically NOT the same, BUT the difference is so little that I would like to consider them the same. 从技术上讲,它们是不一样的,但是差异是如此之小,以至于我想将它们视为相同。
How would I do that? 我该怎么办? :)
:)
Thanks. 谢谢。
Just use ROUND
in MySQL when getting the value from the database. 从数据库获取值时,只需在MySQL中使用
ROUND
。 The following will round to 5 decimal places (which matches your android device value): 以下将舍入到小数点后5位(与您的android设备值匹配):
SELECT ROUND(myValue, 5)
FROM myTable
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.