浮点数后缀f的用法是什么 [英] What's the use of suffix `f` on float value
本文介绍了浮点数后缀f的用法是什么的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想知道C中这两个变量之间的区别:
I am wondering what the difference is between these two variables in C:
float price = 3.00;
和
float price = 3.00f;
在这种情况下,后缀f
有什么用?
What is the use of suffix f
in this case?
推荐答案
3.00
被解释为double
,而不是3.00f
,编译器将其视为float
.
3.00
is interpreted as a double
, as opposed to 3.00f
which is seen by the compiler as a float
.
后缀f
只是告诉编译器哪个是float
和哪个是double
.
The f
suffix simply tells the compiler which is a float
and which is a double
.
请参见 MSDN(C ++)
这篇关于浮点数后缀f的用法是什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文