if we want to declare and allocate the number "4" in an integer variable, the bit state will be something like "..0100".
but the same number "4" in real number data types 4.0, the bit state will be very different.
for ex.
int a = 4 + 4.0;
it can look like it is just 4+4=8, but because "a" is an int variable, the 4.0 float is type casted to an int, then added together to store integer "8" into variable "a".
float f = 10.24f + 20;
float f = 10.24f + (float)20;
these two lines are the same but the 2nd one will be more readable and clear.
'c++' 카테고리의 다른 글
c++ operators (0) | 2024.09.20 |
---|---|
c++ integer data types - 1 (0) | 2024.09.10 |