TH

ระบบเลขฐาน (Number Base System) คือระบบการนับและการเขียนสัญลักษณ์แทนจำนวน โดยกำหนดจำนวนสัญลักษณ์พื้นฐานหรือ "เลขโดด" ที่ใช้ในระบบนั้นๆ ตัวอย่างเช่น ระบบที่เราใช้ในชีวิตประจำวันคือ เลขฐานสิบ ซึ่งมีเลขโดด 10 ตัว (0-9) อย่างไรก็ตาม ในวิทยาการคอมพิวเตอร์ มีการใช้เลขฐานอื่นๆ เช่น ฐานสอง ฐานแปด และฐานสิบหก เพื่อการประมวลผลที่สอดคล้องกับฮาร์ดแวร์

EN

A Number Base System is a method of counting and representing numbers using a specific set of symbols or "digits". For example, our everyday system is Base 10, using 10 digits (0-9). However, in computer science, other bases like Base 2, Base 8, and Base 16 are used for efficient hardware processing.

1

ความเข้าใจเบื้องต้นเกี่ยวกับระบบเลขฐาน Basics of Base Systems

TH

หัวใจหลักของระบบเลขฐานใดๆ (สมมติว่าเป็นฐาน $b$) คือ:

  • จะมีเลขโดดให้ใช้ทั้งหมด $b$ ตัว เริ่มตั้งแต่ $0$ ถึง $b-1$
  • ค่าประจำหลัก (Positional Value) จะเพิ่มขึ้นทีละ $b$ เท่าจากขวาไปซ้าย โดยเริ่มจาก $b^0, b^1, b^2, \dots$
  • สัญลักษณ์การเขียน จะเขียนตัวเลขและห้อยตัวเลขฐานไว้ด้านล่างขวา เช่น $1011_2$ (อ่านว่า หนึ่ง ศูนย์ หนึ่ง หนึ่ง ฐานสอง)
EN

The core concepts of any number base system (let's say base $b$) are:

  • There are exactly $b$ available digits, ranging from $0$ to $b-1$.
  • Positional Value increases by a factor of $b$ from right to left, starting at $b^0, b^1, b^2, \dots$
  • Notation uses a subscript indicating the base after the number, e.g., $1011_2$.
Example 1.1

โดยที่ $d$ คือเลขโดดในแต่ละหลัก และ $b$ คือตัวเลขฐาน

Where $d$ is the digit in each position, and $b$ is the base number.

$$ \text{Value} = (d_n \times b^n) + \dots + (d_1 \times b^1) + (d_0 \times b^0) $$
Example 1.2

ระบบเลขฐาน $b$ จะมีเลขโดดตั้งแต่ $0$ ถึง $b-1$ เสมอ เช่น เลขฐาน 5 จะมีเลขโดดคือ 0, 1, 2, 3 และ 4 (จะไม่มีเลข 5 ปรากฏในฐาน 5)

A base $b$ system always uses digits from $0$ to $b-1$. For instance, Base 5 uses digits 0, 1, 2, 3, and 4 (the digit 5 will not appear).

$$ \begin{aligned} \text{Base } 2 &\implies \{0, 1\} \\ \text{Base } 3 &\implies \{0, 1, 2\} \\ \text{Base } 4 &\implies \{0, 1, 2, 3\} \\ \text{Base } 5 &\implies \{0, 1, 2, 3, 4\} \\ \text{Base } 6 &\implies \{0, 1, 2, 3, 4, 5\} \\ \text{Base } 7 &\implies \{0, 1, 2, 3, 4, 5, 6\} \\ \text{Base } 8 &\implies \{0, 1, 2, 3, 4, 5, 6, 7\} \\ \text{Base } 9 &\implies \{0, 1, 2, 3, 4, 5, 6, 7, 8\} \\ \text{Base } 10 &\implies \{0, 1, 2, 3, 4, 5, 6, 7, 8, 9\} \\ \text{Base } 11 &\implies \{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, \text{A}(10)\} \\ \text{Base } 12 &\implies \{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, \text{A}(10), \text{B}(11)\} \\ \text{Base } 13 &\implies \{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, \text{A}(10), \text{B}(11), \text{C}(12)\} \\ \text{Base } 14 &\implies \{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, \text{A}(10), \text{B}(11), \text{C}(12), \text{D}(13)\} \\ \text{Base } 15 &\implies \{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, \text{A}(10), \text{B}(11), \text{C}(12), \text{D}(13), \text{E}(14)\} \\ \text{Base } 16 &\implies \{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, \text{A}(10), \text{B}(11), \text{C}(12), \text{D}(13), \text{E}(14), \text{F}(15)\} \end{aligned} $$
Example 1.3

หลักที่อยู่ทางขวาสุด (หน้าจุดทศนิยม) คือตำแหน่งที่ 0 มีค่าประจำหลักคือ $b^0$ และจะเพิ่มขึ้นเป็น $b^1, b^2, \dots$ ไปทางซ้ายเรื่อยๆ

The rightmost digit (before the radix point) is position 0 with a weight of $b^0$, increasing to $b^1, b^2, \dots$ towards the left.

$$ \dots \quad b^3 \quad b^2 \quad b^1 \quad b^0 $$
Example 1.4

ตัวเลขที่เขียนเหมือนกันแต่คนละฐาน จะมีค่าไม่เท่ากัน จึงต้องห้อยตัวเลขฐานไว้เสมอ (ยกเว้นฐานสิบที่มักละไว้ในชีวิตประจำวัน)

Numbers written identically but in different bases have different values. A subscript is strictly required (except usually for Base 10).

$$ \begin{aligned} 101_2 &\neq 101_5 \neq 101_{10} \\ 12_3 &\neq 12_4 \neq 12_8 \\ 20_5 &\neq 20_8 \neq 20_{16} \\ 1\text{A}_{12} &\neq 1\text{A}_{15} \neq 1\text{A}_{16} \end{aligned} $$
2

ระบบตัวเลขฐานสิบ Decimal (Base 10)

TH

ระบบตัวเลขที่คุ้นเคยที่สุด มีเลขโดด 10 ตัวคือ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 ค่าประจำหลักคืออำนาจของ 10 ($10^0=1, 10^1=10, 10^2=100, \dots$)

EN

The most familiar system, utilizing 10 digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9. Place values are powers of 10 ($10^0=1, 10^1=10, 10^2=100, \dots$).

Example 2.1

ตัวอย่างการเขียนจำนวนต่างๆ ในรูปการกระจายตามค่าประจำหลัก

Examples of writing various numbers in expanded form using place values.

$$ \begin{array}{ll} 1) & \begin{aligned} 72_{10} &= (7 \times 10^1) + (2 \times 10^0) \\ &= 70 + 2 \\ &= 72 \end{aligned} \\[2em] 2) & \begin{aligned} 3456_{10} &= (3 \times 10^3) + (4 \times 10^2) + (5 \times 10^1) + (6 \times 10^0) \\ &= 3000 + 400 + 50 + 6 \\ &= 3456 \end{aligned} \\[2em] 3) & \begin{aligned} 1045_{10} &= (1 \times 10^3) + (0 \times 10^2) + (4 \times 10^1) + (5 \times 10^0) \\ &= 1000 + 0 + 40 + 5 \\ &= 1045 \end{aligned} \\[2em] 4) & \begin{aligned} 98765_{10} &= (9 \times 10^4) + (8 \times 10^3) + (7 \times 10^2) + (6 \times 10^1) + (5 \times 10^0) \\ &= 90000 + 8000 + 700 + 60 + 5 \\ &= 98765 \end{aligned} \\[2em] 5) & \begin{aligned} 300_{10} &= (3 \times 10^2) + (0 \times 10^1) + (0 \times 10^0) \\ &= 300 + 0 + 0 \\ &= 300 \end{aligned} \\[2em] 6) & \begin{aligned} 1205_{10} &= (1 \times 10^3) + (2 \times 10^2) + (0 \times 10^1) + (5 \times 10^0) \\ &= 1000 + 200 + 0 + 5 \\ &= 1205 \end{aligned} \end{array} $$
Example 2.2

ตัวอย่างการเขียนจำนวนที่มีศูนย์ในรูปการกระจายตามค่าประจำหลัก (กรณีที่เป็นเลข $0$ สามารถละไว้ในการบวกบรรทัดถัดไปได้)

Examples of writing numbers containing zero in expanded form (positions containing $0$ can be omitted in the sum).

$$ \begin{array}{ll} 1) & \begin{aligned} 70809_{10} &= (7 \times 10^4) + (0 \times 10^3) + (8 \times 10^2) + (0 \times 10^1) + (9 \times 10^0) \\ &= 70000 + 0 + 800 + 0 + 9 \\ &= 70000 + 800 + 9 \\ &= 70809 \end{aligned} \\[3em] 2) & \begin{aligned} 50306_{10} &= (5 \times 10^4) + (0 \times 10^3) + (3 \times 10^2) + (0 \times 10^1) + (6 \times 10^0) \\ &= 50000 + 0 + 300 + 0 + 6 \\ &= 50000 + 300 + 6 \\ &= 50306 \end{aligned} \end{array} $$
Example 2.3

ตัวเลขหลังจุดทศนิยม จะใช้เลขชี้กำลังติดลบ เริ่มจาก $-1, -2, -3, \dots$

Digits after the decimal point use negative exponents, starting from $-1, -2, -3, \dots$

$$ \begin{aligned} 12.34_{10} &= (1 \times 10^1) + (2 \times 10^0) + (3 \times 10^{-1}) + (4 \times 10^{-2}) \\ &= 10 + 2 + \frac{3}{10} + \frac{4}{100} \\ &= 10 + 2 + 0.3 + 0.04 \\ &= 12.34 \end{aligned} $$
Example 2.4

เราสามารถใช้หลักการดึงตัวร่วม (Factoring) เพื่อเข้าใจโครงสร้างของพหุนามในฐานสิบได้ ซึ่งเป็นรากฐานของวิธีการหารสั้น

We can use factoring to understand the polynomial structure of base 10, which is the foundation of the short division method.

$$ \begin{aligned} 256_{10} &= (2 \times 10^2) + (5 \times 10^1) + (6 \times 10^0) \\ &= ((2 \times 10) + 5) \times 10 + 6 \\ &= (20 + 5) \times 10 + 6 \\ &= 25 \times 10 + 6 \\ &= 250 + 6 \\ &= 256 \end{aligned} $$
3

ระบบตัวเลขฐานสอง Binary (Base 2)

TH

ภาษาพื้นฐานของคอมพิวเตอร์ (แทนสถานะวงจรเปิด/ปิด) มีเลขโดดเพียง 2 ตัวคือ 0 และ 1 ค่าประจำหลักคืออำนาจของ 2 ($2^0=1, 2^1=2, 2^2=4, 2^3=8, \dots$)

EN

The fundamental language of computers (on/off states). It uses only 2 digits: 0 and 1. Place values are powers of 2 ($2^0=1, 2^1=2, 2^2=4, 2^3=8, \dots$).

Example 3.1

ตัวอย่างการเขียนเลขฐานสองในรูปการกระจายและทำความเข้าใจโครงสร้างหลัก

Examples of writing binary numbers in expanded form and understanding their structural place values.

$$ \begin{array}{ll} 1) & \begin{aligned} 1011_2 &= (1 \times 2^3) + (0 \times 2^2) + (1 \times 2^1) + (1 \times 2^0) \\ &= 8 + 0 + 2 + 1 \\ &= 11_{10} \end{aligned} \\[3em] 2) & \begin{aligned} 110_2 &= (1 \times 2^2) + (1 \times 2^1) + (0 \times 2^0) \\ &= 4 + 2 + 0 \\ &= 6_{10} \end{aligned} \\[3em] 3) & \begin{aligned} 10101_2 &= (1 \times 2^4) + (0 \times 2^3) + (1 \times 2^2) + (0 \times 2^1) + (1 \times 2^0) \\ &= 16 + 0 + 4 + 0 + 1 \\ &= 21_{10} \end{aligned} \\[3em] 4) & \begin{aligned} 1111_2 &= (1 \times 2^3) + (1 \times 2^2) + (1 \times 2^1) + (1 \times 2^0) \\ &= 8 + 4 + 2 + 1 \\ &= 15_{10} \end{aligned} \\[3em] 5) & \begin{aligned} 10001_2 &= (1 \times 2^4) + (0 \times 2^3) + (0 \times 2^2) + (0 \times 2^1) + (1 \times 2^0) \\ &= 16 + 0 + 0 + 0 + 1 \\ &= 17_{10} \end{aligned} \\[3em] 6) & \begin{aligned} 110110_2 &= (1 \times 2^5) + (1 \times 2^4) + (0 \times 2^3) + (1 \times 2^2) + (1 \times 2^1) + (0 \times 2^0) \\ &= 32 + 16 + 0 + 4 + 2 + 0 \\ &= 54_{10} \end{aligned} \end{array} $$
Example 3.2

เนื่องจากเลขฐานสองมีเลขโดดแค่ 0 และ 1 หากปรากฏตัวเลขอื่นจะถือว่าผิดรูปแบบทันที

Since Base 2 uses only 0 and 1, the presence of any other digit makes it invalid.

$$ 1010_2 \quad (\text{ถูกต้อง / Valid}) \quad | \quad 1021_2 \quad (\text{ผิด / Invalid}) $$
Example 3.3

ตัวอย่างการกระจายค่าทศนิยมฐานสอง ซึ่งหลังจุดทศนิยม ค่าประจำหลักจะลดลงทีละครึ่ง ($2^{-1}=\frac{1}{2}, 2^{-2}=\frac{1}{4}, 2^{-3}=\frac{1}{8}, \dots$)

Examples of writing binary fractions in expanded form, where positional values halve at each step ($2^{-1}=\frac{1}{2}, 2^{-2}=\frac{1}{4}, 2^{-3}=\frac{1}{8}, \dots$).

$$ \begin{array}{ll} 1) & \begin{aligned} 0.101_2 &= (1 \times 2^{-1}) + (0 \times 2^{-2}) + (1 \times 2^{-3}) \\ &= \frac{1}{2} + 0 + \frac{1}{8} \\ &= 0.5 + 0 + 0.125 \\ &= 0.625_{10} \end{aligned} \\[4em] 2) & \begin{aligned} 0.1_2 &= 1 \times 2^{-1} \\ &= \frac{1}{2} \\ &= 0.5 \\ &= 0.5_{10} \end{aligned} \\[4em] 3) & \begin{aligned} 0.11_2 &= (1 \times 2^{-1}) + (1 \times 2^{-2}) \\ &= \frac{1}{2} + \frac{1}{4} \\ &= 0.5 + 0.25 \\ &= 0.75_{10} \end{aligned} \\[4em] 4) & \begin{aligned} 0.01_2 &= (0 \times 2^{-1}) + (1 \times 2^{-2}) \\ &= 0 + \frac{1}{4} \\ &= 0 + 0.25 \\ &= 0.25_{10} \end{aligned} \\[4em] 5) & \begin{aligned} 0.111_2 &= (1 \times 2^{-1}) + (1 \times 2^{-2}) + (1 \times 2^{-3}) \\ &= \frac{1}{2} + \frac{1}{4} + \frac{1}{8} \\ &= 0.5 + 0.25 + 0.125 \\ &= 0.875_{10} \end{aligned} \\[4em] 6) & \begin{aligned} 1.01_2 &= (1 \times 2^0) + (0 \times 2^{-1}) + (1 \times 2^{-2}) \\ &= 1 + 0 + \frac{1}{4} \\ &= 1 + 0 + 0.25 \\ &= 1.25_{10} \end{aligned} \end{array} $$
Example 3.4

การเพิ่มค่าทีละ 1 ในระบบฐานสอง: เมื่อหลักใดเป็น 1 แล้วบวกเพิ่มอีก 1 จะต้องทดไปหลักถัดไปทางซ้าย (กลายเป็น 10)

Incrementing by 1 in binary: when a 1 is added to 1, it overflows and carries over to the next left position (becoming 10).

$$ \begin{array}{rccccccc} \text{Base 10:} & 0 & 1 & 2 & 3 & 4 & 5 & 6 \\ \hline \text{Base 2:} & 0_2 & 1_2 & 10_2 & 11_2 & 100_2 & 101_2 & 110_2 \end{array} $$
4

ระบบตัวเลขฐานอื่นๆ ที่ควรทราบ Other Notable Bases

TH

นอกจากฐานสิบและฐานสอง ยังมีเลขฐานอื่นที่ใช้บ่อยในวิทยาการคอมพิวเตอร์:

  • ฐานแปด (Octal): เลขโดด 0, 1, 2, 3, 4, 5, 6, 7
  • ฐานสิบหก (Hexadecimal): มีเลขโดด 16 ตัว เมื่อเกินเลข 9 จะใช้อักษรภาษาอังกฤษแทน:
    0-9, A(10), B(11), C(12), D(13), E(14), F(15)
EN

Besides Decimal and Binary, these are commonly used in computer science:

  • Octal (Base 8): Digits 0, 1, 2, 3, 4, 5, 6, 7
  • Hexadecimal (Base 16): Uses 16 symbols. After 9, English letters are used:
    0-9, A(10), B(11), C(12), D(13), E(14), F(15)
Example 4.1

ระบบเลขฐานแปด (Octal) มีเลขโดดทั้งหมด 8 ตัว ได้แก่ 0 ถึง 7 (จะไม่มีเลข 8 และ 9 ในระบบนี้เด็ดขาด)

The octal base system uses exactly 8 digits, ranging from 0 to 7 (digits 8 and 9 are invalid).

$$ \text{Base } 8 \implies \{0, 1, 2, 3, 4, 5, 6, 7\} $$
Example 4.2

ระบบเลขฐานสิบหก (Hexadecimal) มีเลขโดด 16 ตัว โดยใช้อักษรภาษาอังกฤษ A-F มาช่วยแทนค่า 10-15

The hexadecimal base system uses 16 digits, incorporating English letters A-F to represent values 10-15.

$$ \text{Base } 16 \implies \{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, \text{A}, \text{B}, \text{C}, \text{D}, \text{E}, \text{F}\} $$
Example 4.3

ในระบบฐานสิบหก ตัวอักษรแต่ละตัวจะมีค่าเทียบเท่ากับเลขในระบบฐานสิบดังนี้

In the hexadecimal system, each letter corresponds to a specific decimal value as follows:

$$ \text{A}=10, \quad \text{B}=11, \quad \text{C}=12, \quad \text{D}=13, \quad \text{E}=14, \quad \text{F}=15 $$
Example 4.4

นอกเหนือจากฐานที่ใช้ในคอมพิวเตอร์ ระบบฐานสิบสองก็เป็นที่รู้จักเช่นกัน (เช่น การนับโหล) โดยใช้ A แทน 10 และ B แทน 11

Besides computer bases, the duodecimal (base 12) system is notable (e.g., counting in dozens), using A for 10 and B for 11.

$$ \text{Base } 12 \implies \{0, 1, 2, \dots, 9, \text{A}, \text{B}\} $$
Example 4.5

การนับเลขฐานแปด เมื่อนับถึงเลข 7 แล้วบวกเพิ่มอีก 1 จะต้องทดไปหลักถัดไปทางซ้าย (กลายเป็น 10 ในฐาน 8)

Counting in octal: after reaching 7, adding 1 carries over to the next position (becoming 10 in base 8).

$$ 4_8, \quad 5_8, \quad 6_8, \quad 7_8, \quad 10_8, \quad 11_8, \quad 12_8, \quad \dots $$
Example 4.6

การนับเลขฐานสิบหก จะนับตัวเลข 0-9 ต่อด้วยอักษร A-F เมื่อถึง F แล้วบวก 1 จึงจะมีการทดหลัก

Counting in hex: count 0-9, then A-F. After reaching F, adding 1 causes a carry to the next position.

$$ \text{9}_{16}, \quad \text{A}_{16}, \quad \text{B}_{16}, \quad \text{C}_{16}, \quad \text{D}_{16}, \quad \text{E}_{16}, \quad \text{F}_{16}, \quad 10_{16}, \quad \dots $$
Example 4.7

ตัวอย่างการเขียนตัวเลขที่ผิดรูปแบบ (ตัวเลขในแต่ละหลักต้องน้อยกว่าเลขฐานเสมอ และต้องใช้อักษรตามที่ระบบกำหนดเท่านั้น)

Examples of invalid number representations (digits must always be strictly less than the base, and use only valid characters).

$$ 18_8 \; (\text{Invalid: } 8 \ge 8) \quad \text{|} \quad 2\text{G}_{16} \; (\text{Invalid: } \text{G} \text{ not in Hex}) $$
5

การแปลงเลขฐานใดๆ เป็นฐานสิบ Converting Any Base to Base 10

TH

การแปลงจากเลขฐานใดๆ กลับมาเป็น ฐานสิบ สามารถทำได้โดยใช้วิธี การกระจายผลคูณค่าประจำหลัก โดยนำเลขโดดในแต่ละตำแหน่งคูณกับค่าประจำหลักของมัน (ฐานยกกำลังตำแหน่ง) แล้วนำผลลัพธ์ทั้งหมดมาบวกกัน

EN

Converting any base to Base 10 is done using Place Value Expansion. We multiply each digit by its positional value (the base raised to its position index) and sum all the results.

Example 5.1

จงแปลง $1101_2$ เป็นเลขฐานสิบ

Convert $1101_2$ to Base 10.

$$ \begin{aligned} 1101_2 &= (1 \times 2^3) + (1 \times 2^2) + (0 \times 2^1) + (1 \times 2^0) \\ &= (1 \times 8) + (1 \times 4) + (0 \times 2) + (1 \times 1) \\ &= 8 + 4 + 0 + 1 \\ &= 13_{10} \end{aligned} $$
Example 5.2

จงแปลง $2102_3$ เป็นเลขฐานสิบ

Convert $2102_3$ to Base 10.

$$ \begin{aligned} 2102_3 &= (2 \times 3^3) + (1 \times 3^2) + (0 \times 3^1) + (2 \times 3^0) \\ &= (2 \times 27) + (1 \times 9) + (0 \times 3) + (2 \times 1) \\ &= 54 + 9 + 0 + 2 \\ &= 65_{10} \end{aligned} $$
Example 5.3

จงแปลง $324_5$ เป็นเลขฐานสิบ

Convert $324_5$ to Base 10.

$$ \begin{aligned} 324_5 &= (3 \times 5^2) + (2 \times 5^1) + (4 \times 5^0) \\ &= (3 \times 25) + (2 \times 5) + (4 \times 1) \\ &= 75 + 10 + 4 \\ &= 89_{10} \end{aligned} $$
Example 5.4

จงแปลง $67_8$ เป็นเลขฐานสิบ

Convert $67_8$ to Base 10.

$$ \begin{aligned} 67_8 &= (6 \times 8^1) + (7 \times 8^0) \\ &= (6 \times 8) + (7 \times 1) \\ &= 48 + 7 \\ &= 55_{10} \end{aligned} $$
Example 5.5

จงแปลง $B4_{12}$ เป็นเลขฐานสิบ (จำไว้ว่า A = 10, B = 11)

Convert $B4_{12}$ to Base 10. (Remember A = 10, B = 11)

$$ \begin{aligned} B4_{12} &= (11 \times 12^1) + (4 \times 12^0) \\ &= (11 \times 12) + (4 \times 1) \\ &= 132 + 4 \\ &= 136_{10} \end{aligned} $$
Example 5.6

จงแปลง $2A_{16}$ เป็นเลขฐานสิบ

Convert $2A_{16}$ to Base 10.

$$ \begin{aligned} 2A_{16} &= (2 \times 16^1) + (10 \times 16^0) \\ &= (2 \times 16) + (10 \times 1) \\ &= 32 + 10 \\ &= 42_{10} \end{aligned} $$
Example 5.7

กรณีเป็นทศนิยม เลขชี้กำลังจะติดลบ เริ่มจาก $-1, -2, \dots$ จากซ้ายไปขวา
จงแปลง $10.11_2$ เป็นเลขฐานสิบ

For fractions/decimals, the exponent becomes negative starting from $-1, -2, \dots$ left to right.
Convert $10.11_2$ to Base 10.

$$ \begin{aligned} 10.11_2 &= (1 \times 2^1) + (0 \times 2^0) + (1 \times 2^{-1}) + (1 \times 2^{-2}) \\ &= 2 + 0 + 0.5 + 0.25 \\ &= 2.75_{10} \end{aligned} $$
6

การแปลงฐานสิบเป็นเลขฐานอื่น Converting from Base 10

TH

การแปลงจาก ฐานสิบ เป็นฐานใดๆ ใช้วิธี การหารสั้น (Repeated Division) โดยนำฐานที่ต้องการแปลงมาเป็นตัวหารเรื่อยๆ จนกว่าผลหารจะเป็น 0 แล้วนำ เศษ (Remainder) มาเขียนเรียงจากล่างขึ้นบน

EN

Converting from Base 10 to any base uses Repeated Division. Divide by the target base continuously until the quotient is 0, then read the Remainders from bottom to top.

Example 6.1

จงแปลง $25_{10}$ เป็นเลขฐานสอง โดยนำ 2 ไปหารสั้นเรื่อยๆ (อ่านเศษจากล่างขึ้นบน)

Convert $25_{10}$ to Base 2 using repeated division by 2. (Read remainders from bottom to top)

$$ \begin{array}{r|rl} 2 & 25 & \\ \hline 2 & 12 & \quad \text{R } 1 \\ \hline 2 & 6 & \quad \text{R } 0 \\ \hline 2 & 3 & \quad \text{R } 0 \\ \hline 2 & 1 & \quad \text{R } 1 \\ \hline & 0 & \quad \text{R } 1 \end{array} $$
$$ \text{Ans} = 11001_2 $$
Example 6.2

จงแปลง $14_{10}$ เป็นเลขฐานสาม (หารด้วย 3)

Convert $14_{10}$ to Base 3 (divide by 3).

$$ \begin{array}{r|rl} 3 & 14 & \\ \hline 3 & 4 & \quad \text{R } 2 \\ \hline 3 & 1 & \quad \text{R } 1 \\ \hline & 0 & \quad \text{R } 1 \end{array} $$
$$ \text{Ans} = 112_3 $$
Example 6.3

จงแปลง $58_{10}$ เป็นเลขฐานสี่ (หารด้วย 4)

Convert $58_{10}$ to Base 4 (divide by 4).

$$ \begin{array}{r|rl} 4 & 58 & \\ \hline 4 & 14 & \quad \text{R } 2 \\ \hline 4 & 3 & \quad \text{R } 2 \\ \hline & 0 & \quad \text{R } 3 \end{array} $$
$$ \text{Ans} = 322_4 $$
Example 6.4

จงแปลง $89_{10}$ เป็นเลขฐานห้า (หารด้วย 5)

Convert $89_{10}$ to Base 5 (divide by 5).

$$ \begin{array}{r|rl} 5 & 89 & \\ \hline 5 & 17 & \quad \text{R } 4 \\ \hline 5 & 3 & \quad \text{R } 2 \\ \hline & 0 & \quad \text{R } 3 \end{array} $$
$$ \text{Ans} = 324_5 $$
Example 6.5

จงแปลง $156_{10}$ เป็นเลขฐานแปด (หารด้วย 8)

Convert $156_{10}$ to Base 8 (divide by 8).

$$ \begin{array}{r|rl} 8 & 156 & \\ \hline 8 & 19 & \quad \text{R } 4 \\ \hline 8 & 2 & \quad \text{R } 3 \\ \hline & 0 & \quad \text{R } 2 \end{array} $$
$$ \text{Ans} = 234_8 $$
Example 6.6

จงแปลง $140_{10}$ เป็นเลขฐานสิบสอง (จำไว้ว่า R=10 คือ A, R=11 คือ B)

Convert $140_{10}$ to Base 12. (Remember R=10 is A, R=11 is B)

$$ \begin{array}{r|rl} 12 & 140 & \\ \hline 12 & 11 & \quad \text{R } 8 \\ \hline & 0 & \quad \text{R } 11 \implies \text{B} \end{array} $$
$$ \text{Ans} = B8_{12} $$
Example 6.7

จงแปลง $254_{10}$ เป็นเลขฐานสิบหก (จำไว้ว่า R=14 คือ E, R=15 คือ F)

Convert $254_{10}$ to Base 16. (Remember R=14 is E, R=15 is F)

$$ \begin{array}{r|rl} 16 & 254 & \\ \hline 16 & 15 & \quad \text{R } 14 \implies \text{E} \\ \hline & 0 & \quad \text{R } 15 \implies \text{F} \end{array} $$
$$ \text{Ans} = FE_{16} $$
7

การแปลงข้ามฐาน Inter-base Conversions

TH

การแปลงระหว่าง ฐาน 2, ฐาน 8, และ ฐาน 16 สามารถทำได้รวดเร็วโดยใช้วิธี การจัดกลุ่มเลขโดด เนื่องจากฐาน 8 ($2^3$) ใช้เลขฐานสอง 3 หลัก และฐาน 16 ($2^4$) ใช้เลขฐานสอง 4 หลักต่อ 1 ตัว

EN

Conversions between Base 2, Base 8, and Base 16 can be done rapidly using digit grouping. This is because Base 8 ($2^3$) corresponds to 3 binary bits, and Base 16 ($2^4$) corresponds to 4 binary bits per digit.

Example 7.1

แปลงฐานสองเป็นฐานแปด โดยแบ่งกลุ่มทีละ 3 ตัว จากขวาไปซ้าย
จงแปลง $101110_2$ เป็นฐาน 8

Convert Base 2 to Base 8 by grouping 3 digits from right to left.
Convert $101110_2$ to Base 8.

$$ \begin{aligned} 101110_2 &\implies \underbrace{101}_{5} \quad \underbrace{110}_{6} \\ &\implies 56_8 \end{aligned} $$
Example 7.2

แปลงกลับจากฐานแปดเป็นฐานสอง โดยกระจายตัวเลข 1 ตัว ให้กลายเป็นฐานสอง 3 หลัก
จงแปลง $73_8$ เป็นฐาน 2

Convert Base 8 to Base 2 by expanding 1 digit into 3 binary digits.
Convert $73_8$ to Base 2.

$$ \begin{aligned} 73_8 &\implies \overbrace{111}^{7} \quad \overbrace{011}^{3} \\ &\implies 111011_2 \end{aligned} $$
Example 7.3

แปลงฐานสองเป็นฐานสิบหก โดยแบ่งกลุ่มทีละ 4 ตัว จากขวาไปซ้าย (ถ้าไม่ครบให้เติม 0 ข้างหน้า)
จงแปลง $1011010_2$ เป็นฐาน 16

Convert Base 2 to Base 16 by grouping 4 digits from right to left (pad with 0s if needed).
Convert $1011010_2$ to Base 16.

$$ \begin{aligned} 1011010_2 &\implies \underbrace{0101}_{5} \quad \underbrace{1010}_{\text{A}} \\ &\implies 5\text{A}_{16} \end{aligned} $$
Example 7.4

แปลงจากฐานสิบหกเป็นฐานสอง กระจายเลข 1 ตัวเป็นฐานสอง 4 หลัก
จงแปลง $4\text{F}_{16}$ เป็นฐาน 2

Convert Base 16 to Base 2 by expanding 1 digit into 4 binary digits.
Convert $4\text{F}_{16}$ to Base 2.

$$ \begin{aligned} 4\text{F}_{16} &\implies \overbrace{0100}^{4} \quad \overbrace{1111}^{\text{F}} \\ &\implies 1001111_2 \end{aligned} $$
Example 7.5

แปลงผ่านฐาน 2 เป็นสื่อกลาง: กระจายกลุ่ม 3 แล้วค่อยจับกลุ่ม 4
จงแปลง $345_8$ เป็นฐาน 16

Convert using Base 2 as a bridge: Expand by 3 then Group by 4.
Convert $345_8$ to Base 16.

$$ \begin{aligned} 345_8 &\implies \overbrace{011}^{3} \overbrace{100}^{4} \overbrace{101}^{5} \quad \text{($\rightarrow$ Base 2)} \\ &\implies \underbrace{0000}_{0} \underbrace{1110}_{\text{E}} \underbrace{0101}_{5} \quad \text{($\rightarrow$ Base 16)} \\ &\implies \text{E}5_{16} \end{aligned} $$
Example 7.6

แปลงผ่านฐาน 2 เช่นกัน: กระจายกลุ่ม 4 แล้วค่อยจับกลุ่ม 3
จงแปลง $1\text{C}2_{16}$ เป็นฐาน 8

Similarly, use Base 2: Expand by 4 then Group by 3.
Convert $1\text{C}2_{16}$ to Base 8.

$$ \begin{aligned} 1\text{C}2_{16} &\implies \overbrace{0001}^{1} \overbrace{1100}^{\text{C}} \overbrace{0010}^{2} \quad \text{($\rightarrow$ Base 2)} \\ &\implies \underbrace{000}_{0} \underbrace{111}_{7} \underbrace{000}_{0} \underbrace{010}_{2} \quad \text{($\rightarrow$ Base 8)} \\ &\implies 702_8 \end{aligned} $$
Example 7.7

สำหรับทศนิยม หน้าจุดจัดกลุ่มจากขวาไปซ้าย ส่วนหลังจุดจัดกลุ่มจากซ้ายไปขวา
จงแปลง $110.101_2$ เป็นฐาน 8

For decimals, integer part groups right-to-left, fractional part groups left-to-right.
Convert $110.101_2$ to Base 8.

$$ \begin{aligned} 110.101_2 &\implies \underbrace{110}_{6} \, . \, \underbrace{101}_{5} \\ &\implies 6.5_8 \end{aligned} $$
8

การดำเนินการทางคณิตศาสตร์ในเลขฐาน Math Operations in Number Bases

TH

การบวก ลบ คูณ ในเลขฐานอื่นๆ มีหลักการตั้งทดและขอยืมเหมือนฐานสิบทุกประการ ข้อควรระวังคือ:
"เมื่อผลบวกถึงตัวเลขฐาน จะต้องทดไปหลักข้างหน้า" และ "เมื่อขอยืมค่ามา จะได้ค่าเท่ากับตัวเลขฐานนั้นๆ"

EN

Addition, Subtraction, and Multiplication in other bases follow the exact same logic as Base 10.
"When a sum reaches the base value, carry over", and "When borrowing, the value you get equals the base number".

Example 8.1

จงหาผลบวก $101_2 + 10_2$

Find the sum of $101_2 + 10_2$

$$ \begin{array}{cccc} & 1 & 0 & 1 \\ + & 0 & 1 & 0 \\ \hline & 1 & 1 & 1 \\ \hline \end{array} $$
$$ \text{Ans} = 111_2 $$
Example 8.2

จงหาผลบวก $11_2 + 11_2$ (ตัวเลขสีแดงคือตัวทด)

Find the sum of $11_2 + 11_2$ (Red numbers indicate carry)

$$ \begin{array}{cccc} & \color{red}\small{+1} & \color{red}\small{+1} & \\ & & 1 & 1 \\ + & & 1 & 1 \\ \hline & 1 & 1 & 0 \\ \hline \end{array} $$
$$ \text{Ans} = 110_2 $$
Example 8.3

จงหาผลลบ $101_2 - 11_2$ (ตัวเลขสีแดงคือค่ายืมที่ได้มา)

Find the difference of $101_2 - 11_2$ (Red numbers indicate borrow value)

$$ \begin{array}{cccc} & \color{red}\small{0} & \color{red}\small{2} & \\ & \cancel{1} & \cancel{0} & 1 \\ - & & 1 & 1 \\ \hline & & 1 & 0 \\ \hline \end{array} $$
$$ \text{Ans} = 10_2 $$
Example 8.4

จงหาผลบวก $34_5 + 23_5$ (หลักหน่วย 4+3=7 แปลงเป็นฐาน 5 ได้ $12_5$ เขียน 2 ทด 1)

Find the sum of $34_5 + 23_5$ (Units: 4+3=7 becomes $12_5$, write 2, carry 1)

$$ \begin{array}{cccc} & \color{red}\small{+1} & \color{red}\small{+1} & \\ & & 3 & 4 \\ + & & 2 & 3 \\ \hline & 1 & 1 & 2 \\ \hline \end{array} $$
$$ \text{Ans} = 112_5 $$
Example 8.5

จงหาผลลบ $42_8 - 15_8$ (ยืมมา 1 มีค่าเป็น 8 บวกกับ 2 เป็น 10 แล้วลบ 5)

Find the difference of $42_8 - 15_8$ (Borrow 1 = 8. Add to 2 makes 10, then subtract 5)

$$ \begin{array}{ccc} & \color{red}\small{3} & \color{red}\small{10} \\ & \cancel{4} & \cancel{2} \\ - & 1 & 5 \\ \hline & 2 & 5 \\ \hline \end{array} $$
$$ \text{Ans} = 25_8 $$
Example 8.6

จงหาผลบวก $A5_{16} + 2B_{16}$ (หลักหน่วย 5+11=16 แปลงเป็นฐาน 16 ได้ $10_{16}$ เขียน 0 ทด 1)

Find the sum of $A5_{16} + 2B_{16}$ (Units: 5+11=16 becomes $10_{16}$, write 0, carry 1)

$$ \begin{array}{ccc} & \color{red}\small{+1} & \\ & \text{A} & 5 \\ + & 2 & \text{B} \\ \hline & \text{D} & 0 \\ \hline \end{array} $$
$$ \text{Ans} = D0_{16} $$
Example 8.7

จงหาผลคูณ $101_2 \times 11_2$ (ตั้งคูณตามปกติและใช้กฎการบวกฐานสองตอนรวมผลลัพธ์)

Find the product of $101_2 \times 11_2$ (Multiply normally and use binary addition rules at the end)

$$ \begin{array}{cccc} & & 1 & 0 & 1 \\ \times & & & 1 & 1 \\ \hline & & 1 & 0 & 1 \\ + & 1 & 0 & 1 & 0 \\ \hline & 1 & 1 & 1 & 1 \\ \hline \end{array} $$
$$ \text{Ans} = 1111_2 $$

คำศัพท์ที่น่าสนใจ Key Vocabulary

คำศัพท์คณิตศาสตร์ภาษาอังกฤษ พร้อมรากศัพท์

คำศัพท์ รากศัพท์ / Root ความหมาย / Meaning
Number Base numerus (number) + basis (foundation) ระบบเลขฐาน · ระบบการนับจำนวนที่ใช้จำนวนสัญลักษณ์พื้นฐานจำกัด เช่น ฐานสิบมี 10 ตัว
Digit digitus (finger or toe) เลขโดด · สัญลักษณ์เดี่ยวๆ ที่ใช้เขียนแทนจำนวนในระบบฐานนั้นๆ
Decimal decem (ten) เลขฐานสิบ · ระบบตัวเลขพื้นฐานของมนุษย์ (Base 10) ประกอบด้วย 0-9
Binary bini (two by two) เลขฐานสอง · ระบบตัวเลขของคอมพิวเตอร์ (Base 2) ประกอบด้วย 0 และ 1
Octal octo (eight) เลขฐานแปด · ระบบเลขฐาน 8 (Base 8) ประกอบด้วยเลข 0-7
Hexadecimal hex (six) + decem (ten) เลขฐานสิบหก · ระบบเลขฐาน 16 (Base 16) ใช้ 0-9 และตัวอักษร A-F
Place Value place (position) + valere (be worth) ค่าประจำหลัก · มูลค่าของตัวเลขที่เกิดจากตำแหน่งที่มันอยู่
Remainder re- (back) + manere (to stay) เศษ (จากการหาร) · ตัวเลขที่เหลือจากการหารไม่ลงตัว ใช้ในการแปลงฐาน