c ++基本问题请解决 [英] c++ basic question please resolve

查看:75
本文介绍了c ++基本问题请解决的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

0.0和0.00以及0.0f和0.000f之间有什么区别?

解决方案

没有区别。你显然需要依靠文字的语法以及浮点数据类型的工作原理: http://en.wikipedia.org/wiki/Floating_point [ ^ ]。







没有f的文字是依赖于C ++的实现,可以是float的两倍,但是带有f的文字意味着单精度浮点字面量。所有数值都相同,代表零实数。



(感谢下面Ron Beyer的评论。)



-SA


我知道......0.0和0.00表示 double 类型

i知道...0.0f和0.000f表示 float 类型



例如,

< pre lang =c ++> float a = 0 0 ; // float< = double
float b = 0 00 ; // float< = double
double c = 0 .0f; // double< = float
double d = 0 .00f; // double< = float


what is difference between 0.0 and 0.00 and 0.0f and 0.000f?

解决方案

No difference.You apparently need to lean about the syntax for literal and how floating-point data types work: http://en.wikipedia.org/wiki/Floating_point[^].

[EDIT]

The literal without "f" is implementation dependent in C++, can be double of float, but the ones with "f" mean single-precision floating-point literal. All values are identical and represent zero real number.

(Credit to the comment by Ron Beyer below.)

—SA


i know... "0.0 and 0.00" means double Type
i know... "0.0f and 0.000f" means float Type

for example,

float a = 0.0;   // float <= double
float b = 0.00;   // float <= double
double c = 0.0f;   // double <= float 
double d = 0.00f;   // double <= float 


这篇关于c ++基本问题请解决的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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