|
本帖最后由 城下秋木 于 2021-6-21 17:22 编辑
就是这个问题,我输了一包卫龙辣条,至今还是不懂。我说能输出两位数,但是没设置精度。淦,本来是我的卫龙啊。
先贴一下定义
The precision and scale of a field describe the maximum size and precision of data that can be stored in the field. The precision describes the number of digits that can be stored in the field and the scale describes the number of decimal places for float and double fields. For example, if the field value is 54.234, then scale = 3 and precision = 5.
按照我的理解,小数点好说,就是保留多少位。而精度是接近真值的程度。
小数点为0,精度为0,按照二进制逼近数值;
而上面的54.234,小数点3,精度5。就是保留3位,精度为正负0.00001(大概这个值,应该是吧,我猜的)(大佬们我错了,实践出真知,精度是所有位数包括整数部分,应该为精度为+-00.001)。为什么要精度设置大一点,还是计算机的二进制的值不能完全表示十进制的小数点,因此精度越大越逼近这个值,但是设置太大占用空间会太大。而精度为6是单精度和双精度的分界线,所以例子是较准的单精度。
所以,单精度精度16会出问题吧
|
|