Of int, char, float, and bool, which is smallest?

后端 未结 10 1287
傲寒
傲寒 2021-02-02 09:51

The following is from a \"fill-in at home\" programming test that is part of the application process for an MSc in game development at a UK university:

C+

10条回答
  •  情歌与酒
    2021-02-02 09:55

    No type takes less than char, because by definition sizeof(char) == 1. However, it is entirely possible that all types take the same amount of space.

    (Representing each type with 16 bits (with a suitably unusual floating point format) would suffice to satisfy the standard value range requirements; real hardware where every type has 32 bits exists.)

提交回复
热议问题