MySQL存储浮点数 [英] MySQL storing Floats

查看:450
本文介绍了MySQL存储浮点数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试保存一个很长的浮点数

I am trying to save a float number which is this long

13.00386644742523

13.00386644742523

基本上是Lat和Lng值. 当我将其保存在数据库中时,将其存储为

Its basically Lat and Lng value. when i save it in the database its getting stored as

13.0039

13.0039

推荐答案

基于经验,我对使用ARINC424构建的导航数据库进行了此操作,最终使用了DECIMAL(18,12)将值存储为弧度.

Based on experience I did this for a navigation database built from ARINC424 and eventually used a DECIMAL(18,12) for storing values in radians.

注意:浮点数和双精度词不够精确,可能会导致舍入错误

NOTE: Floats and doubles aren't as precise and may result in rounding errors

要点是,当使用度数或弧度时,我们知道值的范围-小数部分需要最多数字.

The point is that when using degrees or radians we know the range of the values - and the fractional part needs the most digits.

最好的方法是使用 MySQL Spatial Extensions

这篇关于MySQL存储浮点数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆