如何在Visual C ++中将浮点文字处理为double还是float? [英] How a floating point literal is treated either double or float in Visual C++?

查看:108
本文介绍了如何在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)

这篇关于如何在Visual C ++中将浮点文字处理为double还是float?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆