MySQL计算问题:1 + 1 = 1.999999999 [英] Mysql calculation issues: 1+1=1.999999999

查看:294
本文介绍了MySQL计算问题: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屋!

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