在进行浮点计算时,所有常量都是双精度的而不是整数的吗? [英] When doing floating point calculations, are all constants doubles rather than integers?
本文介绍了在进行浮点计算时,所有常量都是双精度的而不是整数的吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
进行浮点计算时,所有常量都是双精度的而不是整数的吗?
why
When doing floating point calculations, are all constants doubles rather than integers?
why
推荐答案
否.但是在进行计算之前,它们将隐式转换为两倍.如果不是这样,系统将很难进行计算.
写完全是有效的
No. But they would be implicitly cast to a double before the calculation went ahead. If they weren''t, the calculation would be much harder for the system to do.
It is perfectly valid to write
double d = 10.3445;
double result = d * 17;
int i = 17;
double result2 = d * i;
在这两种情况下,整数都会在乘法发生之前转换为双精度.
In both cases the integer will be cast to a double before the multiplication occurs.
当计算机计算浮点表达式时,它首先将所有值转换为浮点值.
When the computer evaluates a floating point expression, it first converts all the values to floating ones.
是的,
有关更多详细信息,请参见浮桥表示法.
Yes,
for further details see the floating pont representation.
这篇关于在进行浮点计算时,所有常量都是双精度的而不是整数的吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文