- Although base 10 is the usual way to write numbers in a program, sometimes you want to express a number in octal base or in hex base. To write numbers in octal value, precede the value with 0. Thus, 023 actually means 19 in the base 10. To write numbers in hexadecimal, before the value with 0x or 0X. So 0x23 really means 35 in base 10.
So goodguys = 0x1; really means the same as goodguys = 1;
The first statement is the same as goodguys = 1; The second statement says that we must shift bits to the left by 2 positions. So we are done with
goodguys = 0x100
which matches goodguys = 4;
Now you can make two statements
goodguys = 0x1;
goodguys <2;
as one operator
goodguys = 0x1 <2;
which is similar to what you have. But if you are not familiar with hexadecimal notation and bitwise shift operators, this will look intimidating.
- When const is used with a variable, it uses the following syntax:
const variable-name = value;
In this case, the const modifier allows you to assign the initial value to a variable, which cannot be subsequently changed by the program. For instance
const int POWER_UPS = 4;
will assign 4 to the POWER_UPS variable. But if later you try to overwrite this value, for example
POWER_UPS = 8;
You will get a compilation error.
- Finally, uint32_t means the 32-bit unsigned int type. You will use it if you want your variable to be 32 bits and nothing more.
source share