Consider a code
int16_t x = 1;
int16_t y = 1;
auto v = x + y;
int16_t w = x + y;
cout << sizeof(v) << endl << sizeof(w) << endl;
where I used #include <cstdint>
for fixed size integers. The output is
4
2
Why the sizes of v and w are different, and how do I make the sizes of integers to be fixed during primitive operations ?
Note that, the result for v will be the same if I use a 8-bit integer type instead of int16_t.
Aucun commentaire:
Enregistrer un commentaire