mysql除法精度

更新时间:2023-07-26 20:01:42 阅读: 评论:0

mysql除法精度
Example:
mysql> lect 1*0.00001;
+-----------+
糖果纸
| 1*0.00001 |
楼一幢
+-----------+
| 0.00001 |
+-----------+
Ok, that looks fine. Let's do the same thing using division:
mysql> lect 1/100000;
+----------+
万圣节活动策划方案
青椒蛋炒饭
| 1/100000 |
+----------+
| 0.0000 |
+----------+
Oops! What happened?
The issue is that the maximum precision of the result value depends on the number of decimal places in the arguments. Since the cond version us two whole numbers, the result us the default number of decimal places, which is 4. So you really have to take care to make sure you're getting the precision you want out of your math operations!
To MySQL's credit, (however, I maintain it's still a bit troublesome becau how often would you expect the division operator to have a list of instructions and caveats?)
There are at least a couple simple solutions:
mysql> SELECT CAST(1/100000 AS DECIMAL(8,5) );查看的近义词
+---------------------------------+
| CAST(1/100000 AS DECIMAL(8,5) ) |
+---------------------------------+由衷意思
| 0.00001 |
+---------------------------------+
Or
mysql> SET div_precision_increment=5;
mysql> SELECT 1/100000;
+----------+
| 1/100000 |
松下zs3>计较+----------+
| 0.00001 |
+----------+

本文发布于:2023-07-26 20:01:42,感谢您对本站的认可!

本文链接:https://www.wtabcd.cn/fanwen/fan/82/1118744.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:策划   除法   青椒
相关文章
留言与评论(共有 0 条评论)
   
验证码:
推荐文章
排行榜
Copyright ©2019-2022 Comsenz Inc.Powered by © 专利检索| 网站地图