Quiz · Medium
Two's complement, IEEE 754, endianness, Boolean algebra, adders and CPU basics.
What is the range of an 8-bit two's complement integer?
0 to 255
-127 to 127
-128 to 127
-256 to 255
The leftmost bit has weight -128, so the range is -128 to 127.
The diagram shows an 8-bit two's complement pattern. What value does it represent?
-10
246
-118
10
-128 + 64 + 32 + 16 + 4 + 2 = -10. (Unsigned it would be 246.)
In 8-bit two's complement, what is -5?
10000101
11111011
11111010
00000101
5 = 00000101; invert to 11111010 and add 1 to get 11111011.
What does 0x1F equal in decimal?
15
16
31
32
1 x 16 + 15 = 31.
In IEEE 754 single precision, how many bits are used for the exponent?

5
8
11
23
1 sign + 8 exponent (bias 127) + 23 fraction = 32 bits. Double precision uses 11 exponent bits.
Why does 0.1 + 0.2 not equal exactly 0.3 in binary floating point?
Floating point cannot add
0.1 and 0.2 have no exact binary representation
The CPU rounds incorrectly
Python is slow
Both are stored as rounded binary fractions, so the sum carries a tiny error.
A 32-bit value 0x12345678 is stored little-endian at address 100. Which byte is at address 100?
0x12
0x34
0x56
0x78
Little-endian stores the least significant byte at the lowest address: 78 56 34 12.
Which gate outputs 1 only when its inputs differ?
AND
OR
XOR
NAND
XOR is true when exactly one input is 1.
According to De Morgan's law, NOT (A AND B) equals:
NOT A AND NOT B
NOT A OR NOT B
A OR B
A XOR B
Negating an AND gives the OR of the negations.
What is the carry output of a half adder?
A XOR B
A AND B
A OR B
NOT A
Carry = A AND B and Sum = A XOR B.
In the full-adder diagram, which input is the carry from the previous stage?

A
B
Cin
Cout
Cin is the carry-in; Cout goes to the next stage.
What is the main drawback of a ripple-carry adder?
It cannot add negative numbers
The carry must propagate through every stage, making it slow
It needs a clock
It only adds 4 bits
Delay grows linearly with the width; carry-lookahead adders reduce it.
Which memory element is edge-triggered?
SR latch
D flip-flop
Multiplexer
Decoder
A flip-flop samples its input on a clock edge; a latch is level-sensitive.
Which gate types are universal?
AND and OR
NAND and NOR
XOR and XNOR
NOT only
Any Boolean function can be built from NAND gates alone or NOR gates alone.
Which flag indicates unsigned overflow after an addition?
Zero
Negative
Carry
Parity
Carry is set when there is a carry out of the most significant bit; signed overflow uses the overflow flag.
In the von Neumann diagram, which unit executes instructions' arithmetic?

Control Unit
Arithmetic/Logic Unit
Memory Unit
Input Device
The ALU performs arithmetic and logic operations; the control unit sequences them.
In the fetch diagram, which register holds the address of the next instruction?
MAR
MDR
PC
IR
The program counter provides the address; it is copied to MAR to start the memory read.
A CPU runs a 10^9-instruction program with CPI 2 at 2 GHz. How long does it take?
0.5 s
1 s
2 s
4 s
10^9 x 2 / (2 x 10^9) = 1 second.
Which statement describes a load/store architecture?
Arithmetic instructions read memory directly
Only load and store instructions access memory
Instructions have variable length
It has no registers
In load/store (RISC) designs arithmetic operates on registers only.
How many distinct values can a 12-bit field hold?
144
1024
4096
8192
2^12 = 4096.