Most modern processors store integers using binary representation - with a byte being 8-bits. So a 4-byte number could store 32-bit giving a range of numbers:
- Unsigned numbers in the range 0 to 4294967295 (\$2^{32}\$)
- Signed numbers in the range -2147483648 (\$-2^{31}\$) to 2147483647 (\$2^{31}-1\$). These are typically stored using two's complement.
The exact size of the integer depends on the type you use. For C compilers, these are typically (unsigned) char as 8-bit, (unsigned) short as 16-bit, and then (unsigned) int is typically 32-bit. There is also an (unsigned) long which can be either 32-bit or 64-bit depending on compiler settings and processor.
For variables with a size that is consistent across platforms, you can use the types in <cstdint> - these are (*): (u)int8_t, (u)int16_t, and (u)int32_t, with optionally (u)int64_t and (u)int24_t.
As you have said you wish to store a 4-byte (32-bit) integer. The exact way this is stored in memory depends on the processor - there are two flavours, called the endian-ness of the processor:
- Big-Endian - stores the most significant byte (upper bits) in the lowest memory address. The rest of the bytes are stored in sequentially reducing order of significance.
- Little-Endian - stores the least significant byte (lower bits) the lowest memory address. The rest of the bytes are stored in sequentially increasing order of significance. The STM32F40 falls into this category.
For completeness, fractional numbers are typically stored using IEEE 754 floating point representation is used, with single precision (~7 d.p.) being 32-bit, and double precision (~15 d.p.) taking 64-bit.
(*) (u) determines if signed or unsigned - e.g.uint8_t is unsigned 8-bit, int8_t is signed 8-bit.
inthas specific meaning in the context of a C compiler; pretty much any for any of the STM32 series would have a 32-bit or 4-byte little endianint. But the question is unanswerable because we can't see what data type your program is using, if you have even written one yet. – Chris Stratton Nov 28 '18 at 02:16