Skip to main content

Electronics InformationLesson 12 of 15

Digital Logic and Number Systems

Binary and hexadecimal, bits and bytes, the basic logic gates, and converting between analog and digital.

Table of ContentsShow
  1. Analog and digital
  2. Sampling
  3. Binary
  4. Bits and bytes
  5. Building blocks
  6. Hexadecimal
  7. Logic gates
  8. What you can skip
  9. Where people lose points
  10. Work one in under a minute
  11. Where this leads

Digital logic is the most self-contained topic in the subtest. Nothing here needs Ohm's law, and the truth tables can be read off rather than remembered.

Analog and digital

Analog signals vary continuously. A traditional clock's hands sweep; a loudspeaker cone moves through every position in between.

Digital signals have discrete values, in practice two: high and low, 1 and 0, on and off.

AnalogDigital
Valuescontinuousdiscrete
Noiseaccumulates and degrades the signalrejected, as long as levels stay distinguishable
Copyingdegrades each timeexact
Examplesa vinyl record, a dial gaugea CD, a computer, a digital display

Digital's advantage is noise immunity. A signal that is only ever high or low can be cleaned up and passed on exactly, because small disturbances do not change which of the two states it is. That is the reason digital copies do not degrade, and it is the answer to why digital is preferred.

An analog-to-digital converter (ADC) samples an analog signal and turns it into numbers. A digital-to-analog converter (DAC) does the reverse. A microphone feeding a computer uses the first; a computer feeding a speaker uses the second.

Sampling

The sampling rate is how many times per second the signal is measured, and the bit depth is how many bits record each measurement.

  • A higher sampling rate captures higher-frequency detail.
  • More bits resolve finer differences in level, which improves dynamic range.
  • Data rate = samples per second x bits per sample. 8,000 samples a second at 8 bits is 64,000 bits per second; CD audio at 44,100 samples and 16 bits is 705,600 bits per second for one channel.

Binary

Binary uses only 0 and 1, because a circuit reliably distinguishes two states and not ten.

Place values double: 1, 2, 4, 8, 16, 32, 64, 128.

To read a binary number, add the place values where there is a 1.

1011

The places, right to left, are 1, 2, 4, 8. There are 1s in the 1, 2 and 8 positions.

8 plus 2 plus 1 is 11.

110100

Places from the right: 1, 2, 4, 8, 16, 32. The 1s are at 4, 16 and 32.

32 plus 16 plus 4 is 52.

To convert the other way, subtract the largest place value that fits and repeat.

25 in binary

32 is too big, so start at 16. 25 minus 16 is 9. 8 fits, leaving 1. 4 and 2 do not fit. 1 fits, leaving 0.

So 16, 8 and 1 are on: 11001.

Bits and bytes

TermMeans
Bitone binary digit, a single 0 or 1
Nibble4 bits
Byte8 bits
Kilobyte, megabyte, gigabyteroughly a thousand, a million, a billion bytes

A byte is eight bits, and that is the most asked fact in the topic.

Eight bits give 256 possible values, from 0 to 255, because 2 to the eighth is 256. The number of combinations is 2 raised to the number of bits, which is the general rule: 4 bits give 16 values, 10 bits give 1,024.

Building blocks

PartJob
Clocka steady pulse that provides timing to synchronize operations
Flip-flopstores one bit
Countercounts clock pulses
Memorystores data and instructions; non-volatile memory keeps them without power, which is why firmware lives there
Bufferpasses a signal through unchanged while supplying more drive
Microcontrollera processor, memory and input-output on one chip

A parity bit is simple error detection. With even parity, the extra bit is set so that the total count of 1s is even: a byte with three 1s gets a parity bit of 1. If a bit flips in transit the count comes out wrong, which shows that something changed but not which bit - so parity can detect an error but not correct it. Data is sent in packets for a related reason: a bad packet can be detected and only that one resent.

Hexadecimal

Hexadecimal is base 16, using 0 to 9 and then A through F for 10 to 15.

HexDecimal
A10
B11
C12
D13
E14
F15

Hex exists because one hex digit is exactly four bits, so a byte is exactly two hex digits. That makes long binary strings readable: 11111111 is FF, which is 255.

Recognizing the letters as digits is the level the subtest asks at. A question showing A through F and asking what numbering system it is wants hexadecimal.

Logic gates

A gate takes one or more inputs and produces one output, according to a fixed rule.

GateOutput is 1 when
ANDboth inputs are 1
OReither input is 1
NOTthe single input is 0; it inverts
NANDnot both - the opposite of AND
NORneither - the opposite of OR
XORexactly one input is 1, not both

The names say the rule, which is the useful thing here. AND means both; OR means either; NOT means the opposite; and an N in front of AND or OR means the result is inverted.

The small circle on a symbol's output means inversion. NAND is the AND shape with a circle; NOR is the OR shape with a circle; NOT is a triangle with a circle. Spot the circle and you know the output is flipped, which decodes half the symbols without memorizing them.

XOR is the odd one. It is OR with the both-inputs-high case excluded, which is why it is called exclusive OR. It is 1 when the inputs differ and 0 when they match, and that "different" reading is often the fastest way to answer.

A quick way to answer a gate question without recalling the table: AND is "everything must be true", OR is "at least one must be true", and XOR is "they must disagree". Then apply a circle on the output as a final flip. That covers all six gates with three ideas and one rule.

What you can skip

Across all 1,358 Electronics Information questions in our bank:

  • Hexadecimal conversions. The word "hexadecimal" does not appear in any question. The section above is there so the letters do not throw you; do not spend time drilling hex arithmetic.
  • Boolean algebra and truth-table derivation never appear. The gate questions ask what one gate outputs for given inputs.
  • Sampling theory. Aliasing, the twice-the-highest-frequency rule and quantization error are signal-processing theory, and no question asks them.
  • Binary arithmetic. The binary questions are conversions between binary and decimal, up to about 32. Addition and subtraction in binary are not asked.

Where people lose points

Saying a byte is 4 bits or 16 bits. Eight.

Reading binary place values from the left. They double from the right.

Confusing OR and XOR. OR is true when both are 1; XOR is not.

Missing the circle and answering AND for a NAND gate.

Saying hexadecimal has 15 digits. It has 16, counting zero.

Saying analog is superior because it is continuous. The question is usually about noise, where digital wins.

Work one in under a minute

Convert the binary number 10110 to decimal, and say how many values five bits can represent.

Place values from the right: 1, 2, 4, 8, 16. The 1s sit at 2, 4 and 16.

16 plus 4 plus 2 is 22.

Five bits give 2 to the fifth, which is 32 values, from 0 to 31.

Note that 22 is within 0 to 31, which it must be, and that check is free.

Where this leads

Logic gates are transistors used as switches, and the analog-to-digital conversion here is what connects this topic to the rest of the subtest.

Related lessonsReference

Practice this topic

Check that this lesson stuck. Answer questions on digital logic and number systems only, and see the right answer and why after each one.

Practice Digital Logic and Number Systems questions