drop table if exists d;
create table d(c double) engine=innodb;
insert into d values(1e-15),(1e-16);
select * from d;
在mysql数据库按以上语句建表,输出结果如下:
+-------------------+
| c |
+-------------------+
| 0.000000000000001 |
| 1e-16 |
+-------------------+
为什么1e-15按照正常输出,1e-16输出为1e-16,跪求mysql高人详细解释,感激不尽。
mysql浮点型输出格式问题
- 写回答
- 好问题 0 提建议
- 追加酬金
- 关注问题
- 邀请回答
-
1条回答
- solomon5926 2014-10-05 00:27关注
我估计你用个MySQL版本是5.5,我用的是5.1,处理的方式是小数点后5位开始使用科学计算法,5.5的处理方式是小数点后16位开始使用科学计算法。如果你在字段类型声明中没有指定M和D的值,MySQL就会这样去处理double类型的小数点,如果你指定了M和D值,MySQL就会按照你指定的精度显示。关于M和D的说明如下:
mysql> ? double
Name: 'DOUBLE'
Description:
DOUBLE[(M,D)] [UNSIGNED] [ZEROFILL]A normal-size (double-precision) floating-point number. Permissible
values are -1.7976931348623157E+308 to -2.2250738585072014E-308, 0, and
2.2250738585072014E-308 to 1.7976931348623157E+308. These are the
theoretical limits, based on the IEEE standard. The actual range might
be slightly smaller depending on your hardware or operating system.M is the total number of digits and D is the number of digits following
the decimal point. If M and D are omitted, values are stored to the
limits permitted by the hardware. A double-precision floating-point
number is accurate to approximately 15 decimal places.UNSIGNED, if specified, disallows negative values.
URL: http://dev.mysql.com/doc/refman/5.1/en/numeric-type-overview.html
解决 无用评论 打赏 举报
悬赏问题
- ¥15 如何在scanpy上做差异基因和通路富集?
- ¥20 关于#硬件工程#的问题,请各位专家解答!
- ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
- ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
- ¥30 截图中的mathematics程序转换成matlab
- ¥15 动力学代码报错,维度不匹配
- ¥15 Power query添加列问题
- ¥50 Kubernetes&Fission&Eleasticsearch
- ¥15 報錯:Person is not mapped,如何解決?
- ¥15 c++头文件不能识别CDialog