why sizeof(13.33) is 8 bytes?

后端 未结 5 658
醉酒成梦
醉酒成梦 2020-12-06 18:38

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

5条回答
  •  时光取名叫无心
    2020-12-06 19:07

    Those are the rules of the language.

    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 is a double literal. If sizeof(float) == 4, sizeof(13.33f) == 4 should also hold because 13.33f is a float literal.

提交回复
热议问题