Software Development  ·  Level 6
Discrete Mathematical Concepts
Chapter 3: Apply number system
📚 4 Topics

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.

3.1 Number systems

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.

3.1.1 Definition of terms

A number system consists of a set of symbols and rules used to represent numbers. The following terms are used throughout this unit.

  • Number system: A method of writing numbers using a fixed set of digits and rules. In a software project, the same quantity may be written in decimal on a screen and in binary in memory.
  • Base (Radix): The number of unique digits, including zero, used in a number system. Base 10 uses ten digits, while base 2 uses only two.
  • Digit: An individual symbol used to represent numbers within the system. In base 16 the digits are 0 to 9 and A to F.
  • Bit: A binary digit, either 0 or 1. It is the smallest unit of data a computer stores.
  • Byte: A group of 8 bits. A single byte can hold 2⁸ = 256 different values.
  • Place value: The value of a digit depending on its position within a number. In 4352 the digit 4 is worth 4000 because it sits in the thousands position.
  • Most significant digit: The leftmost digit, which carries the highest place value.
  • Least significant digit: The rightmost digit, which carries the lowest place value (position 0).
  • Representation: How numbers are expressed using digits and place values.
  • Decimal system: The base-10 number system commonly used for everyday counting.

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.

Worked examples

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

3.1.2 Absolute values

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.

Absolute value of a number

The absolute value of any number x is written |x| and defined as follows:

  • |x| = x, if x ≥ 0
  • |x| = -x, if x < 0

Absolute value of a digit

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.

Worked examples

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

3.1.3 Place values

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

Worked examples

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

3.1.4 Types of number systems

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

3.1.4.1 Decimal

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

3.1.4.2 Binary

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:

  • Two digits: Only 0 and 1 are allowed, so a symbol such as 2 makes a number invalid in binary.
  • Bit and byte: Eight bits make one byte, and a byte can hold 2⁸ = 256 different values.
  • Number of values: n bits can represent 2^n different values, so 4 bits give 16 values.
  • Prefix: A leading 0b in source code marks a binary literal, for example 0b1011.
  • Fractions: Some decimal fractions, such as 0.1, cannot be stored exactly in binary, which is why floating-point results in code can show tiny rounding errors.

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

3.1.4.3 Octal

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:

  • Eight digits: Only 0 to 7 are allowed, so 8 and 9 never appear in an octal number.
  • Compact form: One octal digit stands for exactly three bits, so octal numbers are shorter to write than binary ones.
  • Prefix: Python uses 0o, for example 0o755, while some other languages use a leading 0.
  • Historical use: Early computers whose word sizes were multiples of three bits used octal widely in printouts and panels.

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

3.1.4.4 Hexadecimal

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:

  • Sixteen symbols: The digits are 0 to 9 and A to F, and the letters may be written in capitals or small letters.
  • Compact form: A single byte, which needs eight bits in binary, needs only two hexadecimal digits, from 00 to FF.
  • Prefix: 0x marks a hexadecimal literal in most programming languages, for example 0x1A3.
  • Colour codes: A web colour such as #FF5733 is three bytes written as red, green and blue pairs.
  • Addresses: Memory addresses and hardware (MAC) addresses are written in hexadecimal because they are easier to read than long strings of bits.

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

Practice Questions

  1. Identify the base of the number system with digits 0,1,2,3,4,5,6 (2 marks)
  2. Calculate the absolute value of -98 for a hospital’s patient temperature deviation (3 marks)
  3. Find the place value of digit 7 in 3754 (base 10) at position 2 (4 marks)
  4. Convert binary number 11010 to decimal (5 marks)
  5. Convert decimal number 100 to octal (6 marks)
The rest of this chapter
🔒

Create a free account to open more of this chapter.

Free: practical guides, quick cards, workplace scenarios and more.

Create a free account
🔒3.2 Base conversion

Base conversion is essential in discrete mathematics, facilitating communication and computation across different number systems used in various Kenyan professional sectors. For instance, digital record systems in county referral hospitals and financial data p…

🔒3.3 Number systems arithmetic operations

Arithmetic on binary, octal and hexadecimal numbers is what a processor does every time a program adds two counters, calculates a memory offset or compares two values. A software developer who can work these operations by hand can debug register contents, chec…

🔒3.4 Binary codes

Binary codes are agreed patterns of bits that represent decimal digits, characters or positions inside a computer program or digital device. A software developer chooses a code according to the job: BCD for exact decimal digits, ASCII for text, Gray code for p…

Chapter Summary

This 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.

Self-Assessment

🔒 PDFDownload this self-assessment, with answers

Written Assessment

  1. Convert the decimal number 156 to binary. (2 marks)
  2. A county government office uses a binary system for data storage. Convert the binary number \(110101_2\) to decimal. (2 marks)
🔒18 more in this section.

Chapter Examination Questions

🔒 PDFDownload these examination questions, with worked answers

SECTION A (40 Marks) - Answer ALL Questions

  1. Convert the decimal number 245 used in a county hospital patient database to binary and hexadecimal number systems. (4 marks)
  2. Find the absolute value of the daily profit loss recorded as -Ksh 15,000 at a retail shop and explain its significance in business accounting. (4 marks)
🔒18 more in this section.
Flashcards 20 cards Study deck ▾
Question
1

↻ Tap card to reveal answer
🔒

18 more in this section.

Create a free account
Test Yourself 8 questions Start quiz ▾
0%
0 / 2
🔒

6 more in this section.

Create a free account