本文介绍了为什么自动推断此变量为double而不是float?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在下面的代码片段中, auto 将变量推导出为 double ,但是我想要 float .
In the snippet below, auto deduces the variable to double, but I want float.
auto one = 3.5;对于带小数点的文字,是否始终使用 double ?如何确定浮点数和双精度数?
Does it always use double for literals with a decimal point? How does it decide between float and double?
推荐答案文字 3.5 的类型为 double .对于 float ,请使用 3.5f
Type of literal 3.5 is double. For float please use 3.5f
您可以使用此代码段来查看各种类型的信息.
You can play with this snippet to see various type information.
更多推荐
为什么自动推断此变量为double而不是float?
发布评论