Bits, bytes and hexadecimal
The previous topic ended with a memory that holds only numbers: the instruction 0x00B50633, the integers 5 and 7, the 13 bytes of "hello, world\n". A cell does not hold “the number 5”; it holds electrical levels. This topic sets out the interpretations every later note relies on: unsigned and two’s-complement integers, overflow, bitwise ops, endianness and text.
Notation. A -bit vector is , with most significant. is the unsigned reading, the two’s-complement reading. is bitwise complement. Subscripts mark bases: , 0x2C.
A bit is two voltage levels far enough apart that noise rarely flips them. As an unsigned integer,
bits give patterns mapped onto . A byte is 8 bits (the smallest addressed unit). A word is the processor’s natural unit: 32 bits in RV32I, 64 in RV64. Group bits by four for hex: = 0x2C = 44. A byte is two hex digits; a 32-bit word is eight — which is why addresses and machine words are written in hex.
C does not fix integer widths, only minimum ranges. On LP64 Linux/macOS, char is 1 byte, short 2, int 4, long 8 and pointers 8; on ILP32 RISC-V, long and pointers are 4; on 64-bit Windows, long stays 4. Use <stdint.h> (int8_t, uint32_t, int64_t) when width matters.