MySQL计算问题:1 + 1 = 1.999999999 [英] Mysql calculation issues: 1+1=1.999999999
问题描述
问题是这样的,当我从一个表中向视图中添加两个或多个双精度数时,不是给我正确的结果,而是添加了大约十个左右的数字.例如0.5 + 1.5 = 1.99999999998或5.5 + 8.5 = 14.0000000001.有任何想法吗? (我知道这是一个n00b问题,我记得在9年级的考试中不得不处理类似的问题,但我只是不记得那时我是怎么做到的:P)
The problem is this, when I add two or more doubles from a table to a view, instead of giving me the right results, it adds a about ten or so more digits. For example 0.5+1.5=1.99999999998 or 5.5+8.5=14.0000000001. Any ideas? (I know this is sort of n00b question and I remember having to deal with stuff like that in the exams at 9th grade, but I just cannot remember how I did it back then :P)
推荐答案
http://dev.mysql.com/doc/refman/5.0/zh-CN/string-functions.html#function_format
如果那是您的后继,您可以用这种方式设置数字的格式吗?
You can format numbers this way if thats what your after?
这篇关于MySQL计算问题:1 + 1 = 1.999999999的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!