浮点值的后缀“f"有什么用 [英] What's the use of suffix `f` on float value

查看:13
本文介绍了浮点值的后缀“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屋!

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