如何在Visual C ++中将浮点文字处理为double还是float?
问题描述:
假设 float a =(1.5 * b)
其中 b
是浮点数,那么该表达式如何求值? 1.5
是否被视为double或float?
Suppose float a = (1.5 * b)
where b
is float then how is this expression evaluated?
Is 1.5
treated as double or float?
答
1.5是double,使用1.5f进行浮点运算,其实际作用是:
1.5 is double, use 1.5f for float, what it actually does:
float a =(float)(1.5 *(double)b)