Digital Computers
Binary
Characteristics
Only consists of 1 and 2.
Most significant bit (MSB) is on left.
1 byte = 8 bits
Machine code (Assembly) Instruction Set
Data Transfer (read and write memory)
Data Manipulation (change memory)
Program Flow (change next execution)
Programming Language: C
Variables & Types
Variable is text names for addresses in memory. Type is organization and size of memory. Below are some examples of the space occupied by different types in C.
char
8 bits
int
16 bits
unsigned long
32 bits
float
32 bits
In C, signed type using 2's complement form to store the numbers. So, even if two types use the same number of bits, the number range they represent are different.

In the example below, since char
is a signed type and it is 8 bits long. If we assign 128 to it, in binary, it will be 10000000
. As we have discussed before, signed
type means it will use 2's complement form to store its number. In 2's complement representation, 10000000
is -128
. So, the value in f
will be -128
.
int e = 128;
char f = e; // f = -128
Operators
The following table contains operators that manipulate one or two numbers
Arithmetic
+ - * /
Comparison
== != < <= > >=
Logic
! && ||
Bitwise (Do the evaluation on each bit)
& | ^ ~ >> <<
Tips
Include the ASCII code list in the cheatsheet!
Last updated