为什么sizeof(13.33)是8字节? [英] why sizeof(13.33) is 8 bytes?
本文介绍了为什么sizeof(13.33)是8字节?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我给 sizeof(a)
,其中 a = 13.33
,一个float变量,大小为4字节。
但是如果我直接给予 sizeof(13.33)
,则大小为8字节。
When I give sizeof(a)
, where a=13.33
, a float variable, the size is 4 bytes.
But if i give sizeof(13.33)
directly, the size is 8 bytes.
不明白发生了什么。
推荐答案
这些都是语言的规则。
13.33是一个数字文字。它被视为双重,因为它是一个双。如果你想要13.33被当作浮点文字,那么你的状态为13.33f。
13.33 is a numeric literal. It is treated as a double because it is a double. If you want 13.33 to be treated as a float literal, then you state 13.33f.
13.33是一个双字面值。如果sizeof(float)== 4,sizeof(13.33f)== 4也应该成立,因为13.33f是一个浮点文字。
13.33 is a double literal. If sizeof(float) == 4, sizeof(13.33f) == 4 should also hold because 13.33f is a float literal.
这篇关于为什么sizeof(13.33)是8字节?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文