Kenya’s diverse professional sectors frequently require precise numerical understanding applicable across finance, logistics, ICT, healthcare, and agriculture. Mastery of number systems equips diploma students to interpret, convert, and manipulate data accurately, ensuring effective decision-making and problem-solving in workplaces ranging from county government offices to banks and hospitals. This chapter develops calculation skills on number systems, place values, and absolute values, fundamental to discrete mathematics and crucial for all professional fields.
A number system is a set of symbols together with rules for combining them to represent quantities. A software developer meets four of them daily: decimal in user input and reports, binary in the data a processor stores, octal in file permission settings, and hexadecimal in colour codes, memory addresses and debugging output. Knowing the digits, base and place values of each system is the foundation for converting data between formats, performing arithmetic and applying binary codes, which later topics of this chapter develop.
A number system consists of a set of symbols and rules used to represent numbers. The following terms are used throughout this unit.
A subscript or a prefix shows the base when it is not obvious. For example, 1011₂ and 0b1011 both mean a binary number, while 1011₁₀ is the decimal number one thousand and eleven.
Example 1: Identify the base of the number system if the digits used are 0, 1, 2, 3, 4, 5.
Given: Digits = {0, 1, 2, 3, 4, 5}
Base = number of digits = 6
Answer: Base 6
Example 2: Determine the place value of digit 3 in the number 4352 in the decimal system.
Given: Number = 4352 (base 10), digit = 3 at position 2
Place value = digit × base^position
Place value = 3 × 10²
Place value = 3 × 100 = 300
Answer: 300
Example 3: What is the base of a number system if the largest digit used is 9?
Given: Largest digit = 9
Base = largest digit + 1
Base = 9 + 1 = 10
Answer: Base 10
Example 4: In base 8 (octal), what is the base and the digit set?
Given: Base-8 system
Base = 8, digits = {0, 1, 2, 3, 4, 5, 6, 7}
Answer: Base 8, digits 0 to 7
Example 5: What is the decimal equivalent of the single digit 5 in base 6?
Given: Digit 5 in base 6
A single digit keeps its own value in every base that contains it, so the decimal equivalent is 5.
Answer: 5
The absolute value of a number is its distance from zero on the number line, regardless of direction, so it is never negative. In software it is used to measure the size of a difference without caring about its sign, for example the gap between an expected and an actual value in a test, or the size of a refund against a payment in an ordering application. Most programming languages provide an abs() function for this purpose.
The absolute value of any number x is written |x| and defined as follows:
In the study of number systems, the absolute value (also called the face value) of a digit is the value of the digit itself, whatever its position. In the number 4352, the absolute value of 3 is 3, but its place value is 300. The absolute value of a hexadecimal digit such as C is 12, and of F is 15.
Example 1: A test log shows that a function returned a response time 25 ms below the expected value, recorded as -25. Find the size of the deviation.
Given: x = -25
|x| = -x
|x| = -(-25) = 25
Answer: 25 ms
Example 2: Calculate |x| when x = 0 for an account balance that has been cleared in an application.
Given: x = 0
|0| = 0
Answer: 0
Example 3: Find the absolute value of 45, representing a profit of Ksh 45 shown in a sales report.
Given: x = 45
|45| = 45
Answer: Ksh 45
Example 4: A reconciliation script reports a difference of Ksh -150 for a day's till totals. Find the absolute value.
Given: x = -150
|x| = -x
|x| = -(-150) = 150
Answer: Ksh 150
Example 5: A sensor-logging application records a deviation of -7.5 °C. Calculate its absolute value.
Given: x = -7.5
|x| = -x
|x| = -(-7.5) = 7.5
Answer: 7.5 °C
Example 6: State the absolute value of the digit 7 in the octal number 5724, and compare it with its place value.
Given: Digit 7 at position 2 in base 8
Absolute value = 7
Place value = 7 × 8²
Place value = 7 × 64 = 448
Answer: Absolute value 7, place value 448
Place value assigns a value to a digit based on its position in a number. In any base b, the place value of a digit d at position n (counting from the right, starting at 0) is:
place value = d × b^n
The same digit is worth different amounts in different positions, which is why 105 and 501 are different numbers. A developer relies on this when reading a stored value, checking a field width or working out how many digits a number needs.
Place values of the positions in each system:
| Position | 3 | 2 | 1 | 0 |
|---|---|---|---|---|
| Base 10 | 1000 | 100 | 10 | 1 |
| Base 2 | 8 | 4 | 2 | 1 |
| Base 8 | 512 | 64 | 8 | 1 |
| Base 16 | 4096 | 256 | 16 | 1 |
Example 1: Find the place value of digit 4 in 2431 (base 10) at position 2.
Given: d = 4, b = 10, n = 2
Place value = d × b^n
Place value = 4 × 10²
Place value = 4 × 100 = 400
Answer: 400
Example 2: Determine the place value of digit 3 in 1342 (base 5) at position 2.
Given: d = 3, b = 5, n = 2
Place value = d × b^n
Place value = 3 × 5²
Place value = 3 × 25 = 75
Answer: 75
Example 3: Calculate the place value of digit 1 in 1011 (base 2) at position 3.
Given: d = 1, b = 2, n = 3
Place value = d × b^n
Place value = 1 × 2³
Place value = 1 × 8 = 8
Answer: 8
Example 4: Find the place value of digit 5 in 2567 (base 8) at position 2.
Given: d = 5, b = 8, n = 2
Place value = d × b^n
Place value = 5 × 8²
Place value = 5 × 64 = 320
Answer: 320
Example 5: A stock quantity field in an inventory application holds 394 (base 10). Find the place value of digit 9 at position 1.
Given: d = 9, b = 10, n = 1
Place value = d × b^n
Place value = 9 × 10¹
Place value = 9 × 10 = 90
Answer: 90
Four number systems are used in software development: decimal, binary, octal and hexadecimal. They differ in base, in the digits they allow and in where a developer meets them. Programming languages let the programmer write a number in any of these by using a prefix, for example 0b for binary, 0o for octal and 0x for hexadecimal in Python.
| System | Base | Digits | Prefix in code | Typical use |
|---|---|---|---|---|
| Decimal | 10 | 0 to 9 | none | User input, display, prices in Ksh |
| Binary | 2 | 0, 1 | 0b | Data stored and processed by the computer |
| Octal | 8 | 0 to 7 | 0o | File permission settings |
| Hexadecimal | 16 | 0 to 9, A to F | 0x | Colour codes, memory addresses |
Decimal is the base-10 system with the digits 0 to 9. Each position is worth ten times the position to its right, so the place values are 1, 10, 100, 1000 and so on. It is the system a user sees on a screen, for example the price of an item in Ksh 1,250 on a checkout page, even though the computer stores the value in binary internally.
Worked examples:
Example 1: Write 3472 in expanded form using place values.
Given: Digits 3, 4, 7, 2 at positions 3, 2, 1, 0
3 × 10³ + 4 × 10² + 7 × 10¹ + 2 × 10⁰
= 3000 + 400 + 70 + 2
Answer: 3472
Example 2: A developer types 12A into a field that accepts only decimal integers. Is the entry valid?
Given: Valid decimal digits are 0 to 9
The symbol A is not a decimal digit.
Answer: Not valid
Binary is the base-2 system with only two digits, 0 and 1, called bits. Each position is worth twice the position to its right, so the place values are 1, 2, 4, 8, 16, 32, 64, 128 and so on. It is the system used inside the computer because two states, off and on, are easy to store with electronic circuits. For example, an IPv4 address is stored as four bytes, and each of the four numbers in an address such as 192.168.1.10 occupies 8 bits.
Characteristics of binary:
Worked examples:
Example 1: Which of these are valid binary numbers: 10110, 1021, 0b1100?
Given: Valid digits are 0 and 1 only
10110 uses only 0 and 1, so it is valid.
1021 contains 2, so it is not valid.
0b1100 has the binary prefix and uses only 0 and 1, so it is valid.
Answer: 10110 and 0b1100
Example 2: How many different values can a field of 8 bits hold, and what is the highest place value in it?
Given: Number of bits n = 8, base b = 2
Number of values = 2^n
Number of values = 2⁸ = 256
Highest position = 7, so highest place value = 2⁷ = 128
Answer: 256 values, highest place value 128
Octal is the base-8 system with the digits 0 to 7. Each position is worth eight times the position to its right, so the place values are 1, 8, 64, 512 and so on. In software it is most often seen in file permission settings on Unix-like systems: in a command such as chmod 755 script.sh, each of the three digits is an octal digit that sets the permissions for the owner, the group and other users.
Characteristics of octal:
Worked examples:
Example 1: Which of these are valid octal numbers: 745, 389, 7071?
Given: Valid digits are 0 to 7
745 uses only digits from 0 to 7, so it is valid.
389 contains 8 and 9, so it is not valid.
7071 uses only digits from 0 to 7, so it is valid.
Answer: 745 and 7071
Example 2: In the permission setting 755, find the place value of the first digit, 7.
Given: d = 7, b = 8, n = 2
Place value = d × b^n
Place value = 7 × 8²
Place value = 7 × 64 = 448
Answer: 448
Hexadecimal is the base-16 system. It needs sixteen symbols, so the digits 0 to 9 are followed by the letters A to F, which stand for 10 to 15. Each position is worth sixteen times the position to its right, so the place values are 1, 16, 256, 4096 and so on. Developers use it because one hexadecimal digit stands for exactly four bits, so a byte is always two hexadecimal digits. Examples are the colour code #FF5733 in a style sheet, memory addresses in a debugger and the 0x prefix in source code.
| Digit | A | B | C | D | E | F |
|---|---|---|---|---|---|---|
| Value | 10 | 11 | 12 | 13 | 14 | 15 |
Characteristics of hexadecimal:
Worked examples:
Example 1: State the value of the hexadecimal digit E and find its place value at position 1.
Given: E = 14, b = 16, n = 1
Place value = d × b^n
Place value = 14 × 16¹
Place value = 14 × 16 = 224
Answer: Digit value 14, place value 224
Example 2: In the hexadecimal number 1A3, find the place value of the digit A.
Given: d = A = 10, b = 16, n = 1
Place value = d × b^n
Place value = 10 × 16¹
Place value = 10 × 16 = 160
Answer: 160
Example 3: Is 2FG a valid hexadecimal number?
Given: Valid digits are 0 to 9 and A to F
The symbol G is not a hexadecimal digit.
Answer: Not valid
Create a free account to open more of this chapter.
Free: practical guides, quick cards, workplace scenarios and more.
Create a free accountThis chapter introduced the fundamental concepts of number systems, beginning with key definitions, absolute values, and place values that form the basis for understanding different numbering schemes. It explored the main types of number systems including decimal, binary, octal, and hexadecimal, highlighting their unique characteristics and uses. The chapter then detailed methods for converting numbers between these systems, covering conversions from decimal to others, from other systems to decimal, as well as conversions involving binary to and from other bases. Arithmetic operations within these systems were examined, with a focus on binary addition, subtraction, multiplication, and division, including the use of ones and twos complement for subtraction. Octal and hexadecimal arithmetic operations were also discussed, specifically addition and subtraction. Finally, the chapter covered various binary codes such as Binary Coded Decimal (BCD), ASCII, Gray Code, and Excess-3, explaining their applications and how arithmetic operations are performed within BCD. This comprehensive coverage equips students with the necessary skills to work confidently with different number systems and their applications in discrete mathematics.