Chapterبەش 2 · Lectureوانە 2.1

Number Systems and Place Valueسیستەمە ژمارەییەکان و بەهای خانەیی

How place value works in any base; decimal, binary, octal and hexadecimal side by side; bits, nibbles, bytes and words, MSB and LSB; why N bits give 2N2^N patterns; and counting in binary.

چۆن لە هەر کار دەکات؛ ، ، و لە تەنیشت یەکەوە؛ ، ، و ، MSB و LSB؛ بۆچی N 2N2^N شێوە دەدات؛ و ژماردن بە .

17 min read18 خولەک خوێندنەوە · 18 stepsهەنگاو

What you will learnچی فێر دەبیت

  • Explain place value and write any number as a sum of digit × power of the base.
  • Name the base and the digits of decimal, binary, octal and hexadecimal, and use base subscripts.
  • Describe bits, nibbles, bytes and words, and number the bits of a word from LSB to MSB.
  • Work out how many patterns N bits give and the largest value they can hold.
  • Count in binary, octal and hexadecimal.
  • ڕوون بکەیتەوە و هەر ژمارەیەک وەک کۆی × بنووسیت.
  • و ، ، و بناسیت و بەکاربهێنیت.
  • ، ، و وەسف بکەیت و لە LSBـەوە تا MSB ژمارە بکەیت.
  • بزانیت N چەند شێوە دەدات و گەورەترین نرخێک کە هەڵیدەگرێت چەندە.
  • بە ، و بژمێریت.

One number, four ways to write itیەک ژمارە، چوار شێوەی نووسین

What is 10? In everyday life it is ten. But (10)2(10)_2 is two, (10)8(10)_8 is eight and (10)16(10)_{16} is sixteen. The digits are the same; the decides what they mean.

⁦10⁩ چییە؟ لە ژیانی ڕۆژانەدا دەیە. بەڵام (10)2(10)_2 دووە، (10)8(10)_8 هەشتە و (10)16(10)_{16} شازدەیە. هەمان شتن؛ دیاری دەکات واتایان چییە.

Computers work in binary, people think in decimal, and programmers often write octal or hexadecimal because they are short ways of writing binary. This chapter teaches the four and how to move between them. After it, and the chapters that follow, you will be able to:

بە کار دەکەن، خەڵک بە بیر دەکەنەوە و بەرنامەسازەکان زۆرجار یان دەنووسن، چونکە شێوەی کورتی نووسینی . ئەم بەشە چوار و چۆنیەتیی گواستنەوە لە نێوانیاندا فێر دەکات. دوای ئەم بەش و بەشەکانی دواتر دەتوانیت:

  • write values in decimal, binary, octal and hexadecimal (and later in BCD);
  • convert values between these systems;
  • add, subtract and multiply in binary (chapter Binary Arithmetic and Signed Numbers);
  • describe other codes such as Gray, BCD and ASCII (chapter Digital Codes).
Quick checkپشکنینی خێراWhat is the value of (10)8(10)_8 in decimal?نرخی (10)8(10)_8 بە چەندە؟

Place value: where a digit stands mattersبەهای خانەیی: شوێنی تاکژمارە گرنگە

Definitionپێناسە

The value of one place in a number, also called its weight. In base b the places are worth …, b2b^2, b1b^1, b0b^0 and, after the point, b−1b^{-1}, b−2b^{-2}, …

بەهای یەک خانەیە لە ژمارەیەکدا، کە پێی دەگوترێت کێشی خانەکە. لە bـدا بەهای خانەکان بریتییە لە …، b2b^2، b1b^1، b0b^0 و دوای خاڵەکە b−1b^{-1}، b−2b^{-2}، …

In 2598 the digit 5 does not mean five: it means five hundreds, because of the place where it stands. In a every place has a weight, its place value, and each place is worth base times the place on its right. In decimal the weights are 1, 10, 100, 1000 … — the powers of 10.

لە ⁦2598⁩دا 5 واتای پێنج نییە: واتە پێنج سەد، لەبەر ئەو شوێنەی تێیدایە. لە هەر خانەیەک کێشێکی هەیە، کە . بەهای هەر خانەیەک جار بەهای خانەی لای ڕاستیەتی. لە کێشەکان بریتین لە 1، ⁦10⁩، ⁦100⁩، ⁦1000⁩ و هتد، واتە ⁦10⁩.

Two place-value tables. Top: (2598.5)₁₀ with weights 10³=1000, 10²=100, 10¹=10, 10⁰=1, point, 10⁻¹=0.1; digits 2 5 9 8 . 5; products 2000 + 500 + 90 + 8 + 0.5 = 2598.5. Bottom: (1011.01)₂ with weights 2³=8, 2²=4, 2¹=2, 2⁰=1, point, 2⁻¹=0.5, 2⁻²=0.25; digits 1 0 1 1 . 0 1; products 8 + 0 + 2 + 1 + 0 + 0.25 = 11.25.دوو خشتەی بەهای خانەیی. سەرەوە: (2598.5)₁₀ بە کێشەکانی 10³=1000، 10²=100، 10¹=10، 10⁰=1، خاڵ، 10⁻¹=0.1؛ تاکژمارەکان 2 5 9 8 . 5؛ لێکدانەکان 2000 + 500 + 90 + 8 + 0.5 = 2598.5. خوارەوە: (1011.01)₂ بە کێشەکانی 2³=8، 2²=4، 2¹=2، 2⁰=1، خاڵ، 2⁻¹=0.5، 2⁻²=0.25؛ تاکژمارەکان 1 0 1 1 . 0 1؛ لێکدانەکان 8 + 0 + 2 + 1 + 0 + 0.25 = 11.25.
Each digit is multiplied by the place value above it; the products add up to the number.هەر لەگەڵ خۆی لێک دەدرێت، کە لە سەرەوەیەتی؛ کۆی ئەنجامی لێکدانەکان ژمارەکە دەدات.CêIT
(2598.5)10=2×103+5×102+9×101+8×100+5×10−1=2000+500+90+8+0.5(2598.5)_{10} = 2\times10^{3} + 5\times10^{2} + 9\times10^{1} + 8\times10^{0} + 5\times10^{-1} = 2000 + 500 + 90 + 8 + 0.5

After the point the powers are negative: 10−1=11010^{-1} = \tfrac{1}{10}, 10−2=110010^{-2} = \tfrac{1}{100}.

دوای خاڵەکە سالبن: 10−1=11010^{-1} = \tfrac{1}{10} و 10−2=110010^{-2} = \tfrac{1}{100}.

Quick checkپشکنینی خێراIn (2598.5)10(2598.5)_{10}, what is the place value of the digit 9?لە (2598.5)10(2598.5)_{10}دا 9 چەندە؟

Binary Numbers and Base Systems as Fast as PossibleTechquickie · Englishئینگلیزی · 2.4M viewsبینین · 52K likesلایک · Partبەشی 0:48–3:37 (ofلە 5:20)

Place value: each position is worth a power of the base, so the same idea works for base 10, base 2 and others.

: هەر شوێنێک بەقەد بەهای هەیە، بۆیە هەمان بیرۆکە بۆ ⁦10⁩، 2 و ئەوانی تریش کار دەکات.

Chapters 0:48 positional notation, 1:43 base systems, 2:20 other bases; skips intro and outro.

بەشەکان: ⁦0:48⁩ ، ⁦1:43⁩ ، ⁦2:20⁩ تر؛ پێشەکی و کۆتاییەکەی پەخش ناکرێن.

Place value: where a digit stands mattersبەهای خانەیی: شوێنی تاکژمارە گرنگە

The general formulaیاسا گشتییەکە

The same rule works for every base. Write the base as r (for radix, another word for base). A number with n digits before the point and m digits after it is worth:

هەمان یاسا بۆ هەموو کار دەکات. بە r بنووسە (لە radixـەوە، ناوێکی تری ). ژمارەیەک کە n پێش خاڵەکە و m دوای خاڵەکەی هەیە، بەهاکەی ئەمەیە:

N=dn−1 rn−1+⋯+d1 r1+d0 r0+d−1 r−1+d−2 r−2+⋯+d−m r−mN = d_{n-1}\,r^{n-1} + \cdots + d_1\,r^{1} + d_0\,r^{0} + d_{-1}\,r^{-1} + d_{-2}\,r^{-2} + \cdots + d_{-m}\,r^{-m}

Each digit d is multiplied by its place value, a power of r, and all the products are added.

هەر d لە دەدرێت ( rـە) و هەموو لێکدانەکان کۆ دەکرێنەوە.

Two facts follow. A base-r system needs exactly r digits, from 0 to r−1r-1: a digit with the value r would already be written “10”. And “10” in any base means the base itself: (10)2=2(10)_2 = 2, (10)8=8(10)_8 = 8, (10)16=16(10)_{16} = 16.

دوو ڕاستی لێرەوە دەردەکەون. سیستەمێک کە rـە، ڕێک r پێویستە، لە 0 تا r−1r-1: کە بەهاکەی r بێت پێشتر بە «⁦10⁩» دەنووسرێت. هەروەها «⁦10⁩» لە هەر واتە خودی : (10)2=2(10)_2 = 2، (10)8=8(10)_8 = 8، (10)16=16(10)_{16} = 16.

Quick checkپشکنینی خێراWhich of these is not a valid octal number?کامیان ژمارەیەکی دروست نییە؟

Place value: where a digit stands mattersبەهای خانەیی: شوێنی تاکژمارە گرنگە

Where place value comes fromبەهای خانەیی لە کوێوە هاتووە

Quick checkپشکنینی خێراThe Babylonians wrote numbers in a base that we still meet in every hour of 60 minutes. Which base?بابلییەکان ژمارەیان بە دەنووسی کە هێشتا لە هەر کاتژمێرێکی ⁦60⁩ خولەکیدا دەیبینین. کام ؟

Decimal, binary, octal and hexadecimalدەیی، دووانی، هەشتی و شانزەیی

The four number systems of this courseچوار ئەم کۆرسە
SystemسیستەمBaseDigitsExampleنموونەIts value in decimalنرخەکەی بە
Decimal100 1 2 3 4 5 6 7 8 9(259)10(259)_{10}259
Binary20 1(101101)2(101101)_245
Octal80 1 2 3 4 5 6 7(362)8(362)_8242
Hexadecimal160 … 9 A B C D E F(F12)16(\text{F12})_{16}3858

The small number after the bracket is the subscript: it names the base. Without it, “101” could mean one hundred and one, five (101)2(101)_2, sixty-five (101)8(101)_8 or two hundred and fifty-seven (101)16(101)_{16}. So always write the base when it is not decimal.

ژمارە بچووکەکەی دوای کەوانەکە : ناوی دەڵێت. بەبێ ئەو، «⁦101⁩» دەکرێت واتای سەد و یەک بێت، پێنج (101)2(101)_2، شەست و پێنج (101)8(101)_8 یان دووسەد و پەنجا و حەوت (101)16(101)_{16}. بۆیە هەمیشە بنووسە ئەگەر نەبێت.

Hexadecimal needs six extra digits; it borrows the letters A to F شەش زیادەی پێویستە؛ پیتەکانی A تا F بەکاردەهێنێت
Hex digit ABCDEF
Valueنرخ101112131415
Quick checkپشکنینی خێراWhat is the value of the hexadecimal digit C?نرخی C لە چەندە؟

Why octal and hex?بۆچی هەشتی و شانزەیی؟

Why octal and hex at all? Binary numbers get long quickly: (3858)10=(111100010010)2(3858)_{10} = (111100010010)_2. One octal digit stands for exactly 3 bits and one hex digit for exactly 4 bits, so octal and hex are short, safe ways of writing binary. That is why programmers use hex for memory addresses and for colours such as #FF8800: red (FF)16=255(\mathrm{FF})_{16} = 255, green (88)16=136(88)_{16} = 136, blue (00)16=0(00)_{16} = 0.

بۆچی و ؟ ژمارە زوو درێژ دەبن: (3858)10=(111100010010)2(3858)_{10} = (111100010010)_2. یەک ڕێک 3 نیشان دەدات و یەک ڕێک 4 ، بۆیە و شێوەی کورت و پارێزراوی نووسینی . بۆیە بەرنامەسازەکان بۆ ناونیشانی و بۆ ڕەنگەکان بەکاردەهێنن، وەک #FF8800: سوور (FF)16=255(\mathrm{FF})_{16} = 255، سەوز (88)16=136(88)_{16} = 136، شین (00)16=0(00)_{16} = 0.

Quick checkپشکنینی خێراHow many hexadecimal digits do you need to write the 8-bit number (11000101)2(11000101)_2?بۆ نووسینی ژمارە 8 (11000101)2(11000101)_2 چەند پێویستە؟

Bits, bytes and wordsبیتەکان، بایتەکان و وشەکان

The takes information from main memory, works on it and puts the results back. The block of bits it handles in one operation, and moves to or from memory, is called a word. A word can hold a number for a calculation, or one or more characters such as letters, digits and symbols.

لە سەرەکییەوە وەردەگرێت، کاری لەسەر دەکات و ئەنجامەکان دەگەڕێنێتەوە. ئەو کۆمەڵە بە یەکجار کاری لەسەر دەکات و بۆ یان لە دەیگوازێتەوە، پێی دەوترێت . دەتوانێت ژمارەیەک بۆ ژمێرکاری هەڵبگرێت، یان یەک یان چەند نووسەیەک وەک پیت، و هێما.

Word length differs from machine to machine; it is usually between 8 and 64 bits. Today's phones and laptops are 64-bit machines.

درێژیی لە ئامێرێکەوە بۆ ئامێرێکی تر جیاوازە؛ زۆربەی جار لە نێوان 8 و ⁦64⁩ . مۆبایل و ئەمڕۆ ئامێری ⁦64⁩ .

An 8-bit word drawn as eight boxes numbered b7 to b0 from left to right, holding 0 1 0 0 1 1 0 1. Under each box is its weight: 128, 64, 32, 16, 8, 4, 2, 1. Braces mark the high nibble (b7–b4) and the low nibble (b3–b0). MSB, the most significant bit, points to b7 on the left; LSB, the least significant bit, points to b0 on the right. Below: 01001101₂ = 64 + 8 + 4 + 1 = 77.وشەیەکی 8 بیتی وەک هەشت سندووق لە b7 تا b0 لە چەپەوە بۆ ڕاست، کە 0 1 0 0 1 1 0 1 هەڵدەگرن. لە ژێر هەر سندووقێکەوە کێشەکەی نووسراوە: 128، 64، 32، 16، 8، 4، 2، 1. کەوانەکان نیبڵی بەرز (b7–b4) و نیبڵی نزم (b3–b0) دیاری دەکەن. MSB (گرنگترین بیت) ئاماژە بە b7 لە چەپ دەکات؛ LSB (کەمگرنگترین بیت) ئاماژە بە b0 لە ڕاست. لە خوارەوە: 01001101₂ = 64 + 8 + 4 + 1 = 77.
Bits are numbered from the right, starting at 0. The MSB has the biggest weight. لە ڕاستەوە ژمارە دەکرێن و لە 0ـەوە دەست پێدەکەن. MSB گەورەترین کێشی هەیە.CêIT

An N-bit word is drawn as a row of boxes, and the bits are numbered from 00 to N−1N-1, starting at the right. Bit N−1N-1, on the left, has the biggest weight: it is the (MSB). Bit 0, on the right, has the smallest weight: it is the (LSB).

N وەک ڕیزێک سندووق دەکێشرێت و لە ڕاستەوە لە 00 تا N−1N-1 ژمارە دەکرێن. N−1N-1 لە چەپ گەورەترین کێشی هەیە: ئەوە ⁦(MSB)⁩ـە. 0 لە ڕاست بچووکترین کێشی هەیە: ئەوە ⁦(LSB)⁩ـە.

Four bits make a and eight bits a . For bigger units such as kilobyte and megabyte — and why a kilobyte can mean 1,000 or 1,024 bytes — see Bits, bytes and storage units.

چوار پێکدەهێنن و هەشت . بۆ یەکەی گەورەتر وەک و — و بۆچی دەکرێت ⁦1,000⁩ یان ⁦1,024⁩ بێت — بڕوانە بیتەکان، بایتەکان و یەکەکانی هەڵگرتن.

Quick checkپشکنینی خێراIn a 16-bit word, which bit is the MSB?لە ⁦16⁩ ، کام MSBـە؟

Bits, bytes and wordsبیتەکان، بایتەکان و وشەکان

Word, double word, quad wordوشە، وشەی دووقات و وشەی چوارقات

Many books, Windows and x86 programs also use fixed names for groups of bits. They come from the 16-bit Intel 8086 (1978), the first x86 processor, so in these names a word is 16 bits:

زۆر کتێب، Windows و ⁦x86⁩ ناوی جێگیریش بۆ کۆمەڵەکانی بەکاردەهێنن. ئەم ناوانە لە ⁦Intel 8086⁩ـەوە ⁦(1978)⁩ ماونەتەوە، کە یەکەم ⁦x86⁩ بوو و ⁦16⁩ بوو، بۆیە لەم ناوانەدا ⁦16⁩ :

Fixed names for groups of bits (x86 and Windows)ناوە جێگیرەکان بۆ کۆمەڵەکانی (⁦x86⁩ و Windows)
NameناوBitsBytesHex digits Exampleنموونە
4½1(B)16=(1011)2(\mathrm{B})_{16} = (1011)_2
812(CA)16=(11001010)2(\mathrm{CA})_{16} = (11001010)_2
word (WORD) (WORD)1624(1234)16(1234)_{16}
double word (DWORD) (DWORD)3248(12345678)16(12345678)_{16}
quad word (QWORD) (QWORD)64816(0123456789ABCDEF)16(0123456789\mathrm{ABCDEF})_{16}

These names are fixed. A word in the sense of the screen before — the bits a CPU handles in one step — has grown to 64 bits, but a Windows WORD is still 16 bits, so that old programs keep working.

ئەم ناوانە جێگیرن. بە واتای بەشی پێشوو — ئەو کۆمەڵە بە یەک هەنگاو کاری لەسەر دەکات — گەیشتووەتە ⁦64⁩ ، بەڵام WORDـی Windows هێشتا ⁦16⁩ ، بۆ ئەوەی هەر کار بکەن.

Quick checkپشکنینی خێراA program on a 64-bit PC stores a number as a Windows DWORD. How many bits does it use? لەسەر ⁦64⁩ ژمارەیەک وەک DWORDـی Windows هەڵدەگرێت. چەند بەکاردەهێنێت؟

Bits, bytes and wordsبیتەکان، بایتەکان و وشەکان

Which byte comes first?کام بایت یەکەم دێت؟

Quick checkپشکنینی خێراA 16-bit WORD holds (1234)16(1234)_{16}. Which bytes does a little-endian PC put in memory, lowest address first?WORDـێکی ⁦16⁩ (1234)16(1234)_{16} هەڵدەگرێت. کام لە دادەنێت، بە نزمترین ناونیشان دەست پێدەکات؟

Endianness ExplainedAaron Yoo · Englishئینگلیزی · 52K viewsبینین · 2.7K likesلایک

Big-endian and little-endian: which byte of a multi-byte number is stored first in memory and sent first on networks.

و : کاتێک ژمارەیەک لە چەند پێک دێت، کام یەکەم لە هەڵدەگیرێت و یەکەم بەسەر دەنێردرێت.

Chapters: 0:43 little vs big endian, 1:25 representing numbers, 2:04 network byte order.

بەشەکان: ⁦0:43⁩ بەرامبەر ، ⁦1:25⁩ نووسینی ژمارەکان، ⁦2:04⁩ لە .

Bits, bytes and wordsبیتەکان، بایتەکان و وشەکان

How many patterns do N bits give?N بیت چەند شێوە دەدات؟

A word of bits can stand for anything we agree on: numbers, letters, colours, even the kinds of trees in an orchard. The most common uses are numbers and characters.

کە لە پێکهاتووە دەتوانێت هەر شتێک نیشان بدات کە لەسەری ڕێک بکەوین: ژمارە، پیت، ڕەنگ، تەنانەت جۆرەکانی دار لە باخێکدا. باوترین بەکارهێنانەکانی ژمارە و نووسەن.

Each extra bit doubles the number of patterns: 1 bit gives 2 (0, 1); 2 bits give 4 (00, 01, 10, 11); 3 bits give 8. In general an N-bit word has

هەر زیادە ژمارەی شێوەکان دوو هێندە دەکات: 1 2 شێوە دەدات (⁦0⁩، ⁦1⁩)؛ 2 ⁦4 (00⁩، ⁦01⁩، ⁦10⁩، ⁦11⁩)؛ 3 8. بە گشتی N ئەمەندە شێوەی هەیە:

2×2×⋯×2⏟N=2N\underbrace{2 \times 2 \times \cdots \times 2}_{N} = 2^{N}

As unsigned numbers these patterns are the values 0 to 2N−12^N - 1: the largest value is one less than the number of patterns, because one pattern is used for 0.

وەک ئەم شێوانە نرخەکانی 0 تا 2N−12^N - 1ـن: گەورەترین نرخ یەک کەمترە لە ژمارەی شێوەکان، چونکە یەک شێوە بۆ 0 بەکاردێت.

Every extra bit doubles the patternsهەر زیادە شێوەکان دوو هێندە دەکات
Bits NN NNPatterns 2N2^Nشێوەکان 2N2^NLargest value 2N−12^N - 1گەورەترین نرخ 2N−12^N - 1
121
243
387
4 (a nibble)4 ()1615
7128127
8 (a byte)8 ()256255
1665,53665,535
324,294,967,2964,294,967,295
6418,446,744,073,709,551,61618,446,744,073,709,551,615
A row of lampsڕیزێک گڵۆپ

Think of N lamps in a row, each on or off. Add one more lamp: every old pattern now appears twice, once with the new lamp off and once with it on. That is why one extra bit doubles the count.

بیر لە N گڵۆپ بکەرەوە لە ڕیزێکدا، هەر یەکەیان هەڵکراو یان کوژاوە. گڵۆپێکی تر زیاد بکە: هەر شێوەیەکی کۆن ئێستا دوو جار دەردەکەوێت، جارێک لەگەڵ گڵۆپە نوێیەکە کوژاوە و جارێک هەڵکراو. بۆیە یەک زیادە ژمارەکە دوو هێندە دەکات.

Where the analogy stops workingسنووری ئەم نموونەیە

Lamps are only a picture: a 64-bit word has about 18 billion billion patterns, far more than any row of lamps could ever show one by one.

گڵۆپەکان تەنها وێنەیەکن: ⁦64⁩ نزیکەی ⁦18⁩ ملیار ملیار شێوەی هەیە، زۆر زیاتر لەوەی هیچ ڕیزە گڵۆپێک بتوانێت یەک یەک پیشانیان بدات.

Quick checkپشکنینی خێراHow many different values can one byte hold?یەک چەند نرخی جیاواز دەتوانێت هەڵبگرێت؟

Bits, bytes and wordsبیتەکان، بایتەکان و وشەکان

The weights of a binary numberکێشەکانی ژمارەیەکی دووانی

Because one bit has only two states, each place in a binary number is worth twice the place on its right. Starting from the right, the bits count the 1s, 2s, 4s, 8s, 16s … of the number. For a 7-bit word:

چونکە یەک تەنها دوو دۆخی هەیە، هەر خانەیەک لە ژمارەیەکی دوو هێندەی خانەی لای ڕاستی دەهێنێت. لە ڕاستەوە، ژمارەی یەکەکان، دووەکان، چوارەکان، هەشتەکان، شازدەکان و هتد لە ژمارەکەدا دەژمێرن. بۆ 7 :

b626+b525+b424+b323+b222+b121+b020b_6 2^{6} + b_5 2^{5} + b_4 2^{4} + b_3 2^{3} + b_2 2^{2} + b_1 2^{1} + b_0 2^{0}

The largest 7-bit value is (1111111)2=64+32+16+8+4+2+1=127(1111111)_2 = 64 + 32 + 16 + 8 + 4 + 2 + 1 = 127, and the smallest is (0000000)2=0(0000000)_2 = 0. Check it with the rule: 27−1=1272^7 - 1 = 127.

گەورەترین نرخی 7 (1111111)2=64+32+16+8+4+2+1=127(1111111)_2 = 64 + 32 + 16 + 8 + 4 + 2 + 1 = 127ـە و بچووکترینیان (0000000)2=0(0000000)_2 = 0. بە یاساکە بیپشکنە: 27−1=1272^7 - 1 = 127.

After the the weights go on halving: 2−1=0.52^{-1} = 0.5, 2−2=0.252^{-2} = 0.25, 2−3=0.1252^{-3} = 0.125, 2−4=0.06252^{-4} = 0.0625. So (1011.01)2=8+2+1+0.25=11.25(1011.01)_2 = 8 + 2 + 1 + 0.25 = 11.25, as the place-value picture shows.

دوای کێشەکان بەردەوام نیوە دەبنەوە: 2−1=0.52^{-1} = 0.5، 2−2=0.252^{-2} = 0.25، 2−3=0.1252^{-3} = 0.125، 2−4=0.06252^{-4} = 0.0625. بۆیە (1011.01)2=8+2+1+0.25=11.25(1011.01)_2 = 8 + 2 + 1 + 0.25 = 11.25، وەک وێنەی پیشانی دەدات.

Quick checkپشکنینی خێراWhat is the largest value of an 8-bit unsigned number?گەورەترین نرخی ژمارەیەکی 8 بێنیشانە چەندە؟

Counting in binaryژماردن بە دووانی

You count in binary exactly as in decimal, but you run out of digits after 1. In decimal, after 9 the digit goes back to 0 and you carry 1 to the next place: 9→109 \to 10, 99→10099 \to 100. In binary the same happens after 1: 1→101 \to 10, 11→10011 \to 100, 111→1000111 \to 1000.

بە ڕێک وەک دەژمێریت، بەڵام دوای 1 تەواو دەبن. لە دوای 9 دەگەڕێتەوە بۆ 0 و 1 دەگوازیتەوە بۆ خانەی دواتر: 9→109 \to 10، 99→10099 \to 100. لە هەمان شت دوای 1 ڕوودەدات: 1→101 \to 10، 11→10011 \to 100، 111→1000111 \to 1000.

Three lamps with the weights 2² = 4, 2¹ = 2 and 2⁰ = 1 above them and a bit box under each. The counter steps from 000 = 0 up to 111 = 7; each frame lights the lamps of the 1 bits, marks the bits that just changed, and shows the sum, for example 101₂ = 4 + 1 = 5. The last frame shows 000 … 111: 2³ = 8.
Counting from 0 to 7 with 3 bits. Orange boxes are the bits that changed in this step.ژماردن لە 0 تا 7 بە 3 . سندووقە پرتەقاڵییەکان ئەو کە لەم هەنگاوەدا گۆڕان.CêIT
A taxi's kilometre counterکیلۆمەترپێوی تەکسی

An old taxi has a mechanical kilometre counter: wheels with the digits 0 to 9. When the right wheel passes 9 it goes back to 0 and pushes the next wheel one step. A binary counter is the same machine with wheels that carry only 0 and 1, so it rolls over after every 1.

تەکسییەکی کۆن کیلۆمەترپێوێکی میکانیکیی هەیە: چەند خولاوەیەک کە 0 تا 9یان لەسەرە. کاتێک خولاوەی ڕاست لە 9 تێدەپەڕێت، دەگەڕێتەوە بۆ 0 و خولاوەی دواتر یەک هەنگاو دەجووڵێنێت. هەمان ئامێرە بەڵام خولاوەکانی تەنها 0 و 1یان لەسەرە، بۆیە دوای هەر 1ـێک دەگەڕێتەوە سەر 0.

Where the analogy stops workingسنووری ئەم نموونەیە

You can see an odometer wheel half-way between two digits; a digital counter has no in-between — all its bits change together at one clock tick.

دەتوانیت خولاوەیەکی کیلۆمەترپێو ببینیت کە لە نیوەی نێوان دوو ؛ هیچ دۆخێکی نێوانی نییە — هەموو لە یەک لێدانی کاتژمێردا پێکەوە دەگۆڕێن.

Quick checkپشکنینی خێراWhen you count in binary, what comes right after (1011)2(1011)_2?کاتێک بە دەژمێریت، ڕاستەوخۆ دوای (1011)2(1011)_2 چی دێت؟

Binary - The SIMPLEST explanation of Counting and Converting Binary numbersPractical Networking · Englishئینگلیزی · 575K viewsبینین · 18K likesلایک · Partبەشی 0:42–7:29 (ofلە 22:15)

Counting in binary the same way as in decimal: a place rolls over and carries when it runs out of digits.

ژماردن بە هەر وەک ژماردن بە : کاتێک خانەیەک تەواو دەبن، دەگەڕێتەوە بۆ 0 و دەداتە خانەی دواتر.

Chapter 0:42 "How to count in binary" only (to 7:29).

تەنها بەشی ⁦0:42⁩، How to count in binary (تا ⁦7:29⁩).

Counting in binaryژماردن بە دووانی

0 to 15 in four systems0 تا ⁦15⁩ لە چوار سیستەمەکەدا

0 to 15 in the four systems — worth learning by heart0 تا ⁦15⁩ لە چوار سیستەمەکەدا — باشە لەبەری بکەیت
DecimalBinaryOctalHex
0000000
1000111
2001022
3001133
4010044
5010155
6011066
7011177
81000108
91001119
10101012A
11101113B
12110014C
13110115D
14111016E
15111117F

Look at the octal column: after 7 comes 10 (eight). In the hex column: after 9 come A, B, … F, and only after F comes 10 (sixteen). Every system rolls over when it runs out of digits.

سەیری ستوونی بکە: دوای 7 ژمارەی ⁦10⁩ دێت (هەشت). لە ستوونی : دوای 9 پیتەکانی A، B، … F دێن و تەنها دوای F ژمارەی ⁦10⁩ دێت (شازدە). هەموو سیستەمێک کاتێک تەواو دەبن، دەگەڕێتەوە سەر سفر و یەک دەگوازێتەوە.

Quick checkپشکنینی خێراIn hexadecimal, what comes right after (19)16(19)_{16}?لە ڕاستەوخۆ دوای (19)16(19)_{16} چی دێت؟

Three kinds of conversionسێ جۆر گۆڕینی بنچینە

Changing a number from one base to another is called . There are three kinds, and each has its own lesson:

گۆڕینی ژمارەیەک لە بۆ تر پێی دەوترێت . سێ جۆری هەیە و هەر یەکەیان وانەی تایبەتی خۆی هەیە:

Quick checkپشکنینی خێراTo convert (725)8(725)_8 to hexadecimal, which way is the easiest?بۆ گۆڕینی (725)8(725)_8 بۆ ، کام ڕێگا ئاسانترینە؟

Common mistakesهەڵە باوەکان

MistakeهەڵەFixچارەسەر
Writing the digit 8 or 9 in an octal number, or 2 in a binary number.نووسینی 8 یان 9 لە ژمارەیەکی ، یان 2 لە ژمارەیەکی .A base-rr system has only the digits 0 to r−1r-1.سیستەمی rr تەنها 0 تا r−1r-1ـی هەیە.
Reading (10)2(10)_2 as “ten”.خوێندنەوەی (10)2(10)_2 وەک «دە».Say “one-zero in binary”; its value is two.بڵێ «یەک-سفر بە »؛ نرخەکەی دووە.
Numbering bits from 1.ژمارەکردنی لە 1ـەوە.Bits are numbered from 0 at the right: b0b_0 is the LSB, bN−1b_{N-1} the MSB. لە ڕاستەوە لە 0ـەوە ژمارە دەکرێن: b0b_0 LSBـە و bN−1b_{N-1} MSBـە.
“The MSB is always 1.”«MSB هەمیشە 1ـە.»The MSB names a position, the left-hand bit. In 0110 the MSB, b3b_3, is 0.MSB ناوی شوێنێکە: لای چەپ. لە ژمارەی ⁦0110⁩ـدا MSB، واتە b3b_3، 0ـە.
“8 bits can hold the value 256.”«8 دەتوانێت نرخی ⁦256⁩ هەڵبگرێت.»8 bits give 256 patterns, 0 to 255. The largest value is 2N−12^N - 1.8 ⁦256⁩ شێوە دەدات، 0 تا ⁦255⁩. گەورەترین نرخ 2N−12^N - 1ـە.
Leaving out the base: writing 101 when you mean binary.نەنووسینی : نووسینی ⁦101⁩ کاتێک مەبەستت .Write (101)2(101)_2; without the subscript a reader assumes decimal.(101)2(101)_2 بنووسە؛ بەبێ خوێنەر وا دادەنێت .
Thinking A–F in hex are letters or variables.وا بیرکردنەوە کە ⁦A–F⁩ لە پیت یان .They are digits with the values 10 to 15.ئەوانە بە نرخەکانی ⁦10⁩ تا ⁦15⁩.

Exercisesڕاهێنانەکان

ExerciseڕاهێنانExpand by place valueبە بەهای خانەیی بیکەرەوە

Write (3706.25)10(3706.25)_{10} as a sum of digits times powers of 10.

(3706.25)10(3706.25)_{10} وەک کۆی جار ⁦10⁩ بنووسە.

Show answerوەڵامەکە پیشان بدە
(3706.25)10=3×103+7×102+0×101+6×100+2×10−1+5×10−2(3706.25)_{10} = 3\times10^{3} + 7\times10^{2} + 0\times10^{1} + 6\times10^{0} + 2\times10^{-1} + 5\times10^{-2}
ExerciseڕاهێنانValid or not?دروستە یان نا؟

Which of these numbers are written correctly? (1012)2(1012)_2, (777)8(777)_8, (89)8(89)_8, (1G)16(1G)_{16}, (FACE)16(\text{FACE})_{16}

کام لەم ژمارانە بە دروستی نووسراون؟ (1012)2(1012)_2، (777)8(777)_8، (89)8(89)_8، (1G)16(1G)_{16}، (FACE)16(\text{FACE})_{16}

Show answerوەڵامەکە پیشان بدە
  • Valid: (777)8(777)_8 and (FACE)16(\text{FACE})_{16}.
  • Not valid: (1012)2(1012)_2 (binary has no 2), (89)8(89)_8 (octal has no 8 or 9), (1G)16(1G)_{16} (hex stops at F).
  • دروست: (777)8(777)_8 و (FACE)16(\text{FACE})_{16}.
  • هەڵە: (1012)2(1012)_2 ( 2ـی نییە)، (89)8(89)_8 ( 8 و 9ـی نییە)، (1G)16(1G)_{16} ( لە F دەوەستێت).
ExerciseڕاهێنانCodes for a classکۆد بۆ پۆلێک

A teacher wants to give each of 30 students a different binary code, all of the same length. How many bits are needed?

مامۆستایەک دەیەوێت بە هەر یەک لە ⁦30⁩ قوتابی کۆدێکی جیاواز بدات، هەموو بە هەمان درێژی. چەند پێویستە؟

Hintئاماژە

Find the smallest NN with 2N≥302^N \ge 30.

بچووکترین NN بدۆزەرەوە کە 2N≥302^N \ge 30.

Show answerوەڵامەکە پیشان بدە

4 bits give only 24=162^4 = 16 codes — too few. 5 bits give 25=322^5 = 32 codes, enough for 30. Answer: 5 bits.

4 تەنها 24=162^4 = 16 کۆد دەدات — کەمە. 5 25=322^5 = 32 کۆد دەدات، بەسە بۆ ⁦30⁩. وەڵام: 5 .

ExerciseڕاهێنانLargest valuesگەورەترین نرخەکان

What is the largest unsigned value that fits in (a) 10 bits, (b) 12 bits?

گەورەترین نرخی بێنیشانە کە جێی دەبێتەوە لە (أ) ⁦10⁩ ، (ب) ⁦12⁩ چەندە؟

Show answerوەڵامەکە پیشان بدە
(a) 210−1=1023(b) 212−1=4095\text{(a)}\ 2^{10}-1 = 1023 \qquad \text{(b)}\ 2^{12}-1 = 4095
ExerciseڕاهێنانMemory sizes as powers of 2قەبارەی بیرگە وەک توانی 2

Each byte of memory has its own number, its . Write each memory size in bytes as a power of 2, then say how many bits an address needs to number every byte: (a) 1 KiB; (b) 64 KiB; (c) 1 MiB; (d) 16 MiB; (e) 4 GiB; (f) 16 EiB.

هەر ژمارەی تایبەتی خۆی هەیە، واتە . هەر قەبارەیەکی بە وەک 2 بنووسە، پاشان بڵێ ناونیشانێک چەند پێویستە تا هەموو ژمارە بکات: (أ) ⁦1 KiB⁩؛ (ب) ⁦64 KiB⁩؛ (ج) ⁦1 MiB⁩؛ (د) ⁦16 MiB⁩؛ (هـ) ⁦4 GiB⁩؛ (و) ⁦16 EiB⁩.

Hintئاماژە

1 KiB=2101\ \mathrm{KiB} = 2^{10}, 1 MiB=2201\ \mathrm{MiB} = 2^{20}, 1 GiB=2301\ \mathrm{GiB} = 2^{30} and 1 EiB=2601\ \mathrm{EiB} = 2^{60} bytes. Multiplying powers of 2 adds the exponents: 8×210=23×210=2138 \times 2^{10} = 2^{3} \times 2^{10} = 2^{13}.

1 KiB=2101\ \mathrm{KiB} = 2^{10}، 1 MiB=2201\ \mathrm{MiB} = 2^{20}، 1 GiB=2301\ \mathrm{GiB} = 2^{30} و 1 EiB=2601\ \mathrm{EiB} = 2^{60} . لێکدانی 2 واتە کۆکردنەوەی ئەو ژمارە بچووکانەی لە سەرەوەن: 8×210=23×210=2138 \times 2^{10} = 2^{3} \times 2^{10} = 2^{13}.

Show answerوەڵامەکە پیشان بدە
SizeقەبارەBytes as a power of 2 وەک 2Address bits ناونیشان
(a) 1 KiB(أ) ⁦1 KiB⁩2102^{10}10
(b) 64 KiB(ب) ⁦64 KiB⁩26×210=2162^{6} \times 2^{10} = 2^{16}16
(c) 1 MiB(ج) ⁦1 MiB⁩2202^{20}20
(d) 16 MiB(د) ⁦16 MiB⁩24×220=2242^{4} \times 2^{20} = 2^{24}24
(e) 4 GiB(هـ) ⁦4 GiB⁩22×230=2322^{2} \times 2^{30} = 2^{32}32
(f) 16 EiB(و) ⁦16 EiB⁩24×260=2642^{4} \times 2^{60} = 2^{64}64

N address bits give 2N2^N addresses — the rule of How many patterns. Real processors and their address lines are in Registers and buses. Many books write these binary sizes as KB, MB, GB and EB; why that is unclear: 1,000 or 1,024?

N ناونیشان 2N2^N ناونیشان دەدات — هەمان یاسای ژمارەی شێوەکانـە. پرۆسێسەرە ڕاستەقینەکان و هێڵەکانی ناونیشانیان لە تۆمارگەکان و تێپەڕگەکاندا باس کراون. زۆر کتێب ئەم قەبارە بە KB، MB، GB و EB دەنووسن؛ بۆچی ئەمە ڕوون نییە: ⁦1,000⁩ یان ⁦1,024⁩؟

ExerciseڕاهێنانKeep countingبەردەوام بژمێرە

Write the next three numbers after (a) (1101)2(1101)_2, (b) (17)8(17)_8, (c) (2E)16(2E)_{16}.

سێ ژمارەی دوای ئەمانە بنووسە: (أ) (1101)2(1101)_2، (ب) (17)8(17)_8، (ج) (2E)16(2E)_{16}.

Show answerوەڵامەکە پیشان بدە
  • (a) 1110, 1111, 10000
  • (b) 20, 21, 22 — after 7 the octal digit rolls over
  • (c) 2F, 30, 31 — after F the hex digit rolls over
  • (أ) ⁦1110⁩، ⁦1111⁩، ⁦10000⁩
  • (ب) ⁦20⁩، ⁦21⁩، ⁦22⁩ — دوای 7 دەگەڕێتەوە سەر 0
  • (ج) ⁦2F⁩، ⁦30⁩، ⁦31⁩ — دوای F دەگەڕێتەوە سەر 0
ExerciseڕاهێنانRead a byteبایتێک بخوێنەوە

In the 8-bit word 10010110, what are the MSB and the LSB, and what is the value of the word?

لە 8 ⁦10010110⁩دا، MSB و LSB چین و نرخی چەندە؟

Show answerوەڵامەکە پیشان بدە

MSB =b7=1= b_7 = 1 and LSB =b0=0= b_0 = 0. Value: 128+16+4+2=150128 + 16 + 4 + 2 = 150.

MSB =b7=1= b_7 = 1 و LSB =b0=0= b_0 = 0. نرخ: 128+16+4+2=150128 + 16 + 4 + 2 = 150.

Summaryپوختە

  • In a positional number system each place has a place value, a power of the base r; a number is the sum of digit × place value.
  • Decimal (base 10, digits 0–9), binary (2, 0–1), octal (8, 0–7), hexadecimal (16, 0–9 and A–F, which stand for 10–15). Always write the base as a subscript.
  • A word is the group of bits the CPU handles at once (8 to 64 bits). Bits are numbered b0b_0 (LSB, right) to bN−1b_{N-1} (MSB, left).
  • N bits give 2N2^N patterns; the largest unsigned value is 2N−12^N - 1 (127 for 7 bits, 255 for a byte).
  • Binary weights double to the left (1, 2, 4, 8 …) and halve to the right of the point (0.5, 0.25 …).
  • Counting rolls over when a base runs out of digits: binary after 1, octal after 7, hex after F.
  • Fixed names in x86 and Windows: nibble 4, byte 8, word 16, double word 32, quad word 64 bits. Byte order (endianness) says which byte of a word is stored first.
  • لە بۆ هەر خانەیەک rـە؛ ژمارە کۆی × .
  • ( ⁦10⁩، ⁦0–9⁩)، (⁦2⁩، ⁦0–1⁩)، (⁦8⁩، ⁦0–7⁩)، (⁦16⁩، ⁦0–9⁩ و ⁦A–F⁩ کە واتە ⁦10–15⁩). هەمیشە وەک بنووسە.
  • ئەو کۆمەڵە کە بە یەکجار کاری لەسەر دەکات (⁦8⁩ تا ⁦64⁩ ). لە b0b_0 (LSB، ڕاست) تا bN−1b_{N-1} (MSB، چەپ) ژمارە دەکرێن.
  • N 2N2^N شێوە دەدات؛ گەورەترین نرخی بێنیشانە 2N−12^N - 1ـە (⁦127⁩ بۆ 7 ، ⁦255⁩ بۆ ).
  • کێشەکانی بەرەو چەپ دوو هێندە دەبن (⁦1⁩، 2، 4، 8 …) و لە ڕاستی خاڵەکەوە نیوە دەبنەوە (⁦0.5⁩، ⁦0.25⁩ …).
  • ژماردن کاتێک تەواو دەبن دەگەڕێتەوە سەر سفر: دوای 1، دوای 7، دوای F.
  • ناوە جێگیرەکانی ⁦x86⁩ و Windows: 4، 8، ⁦16⁩، ⁦32⁩، ⁦64⁩ . دەڵێت کام یەکەم هەڵدەگیرێت.
Review questionsپرسیارەکانی پێداچوونەوە
What does (10)16(10)_{16} equal in decimal, and why?(10)16(10)_{16} بە دەیی یەکسانە بە چی و بۆچی؟

16: “10” in any base means one group of the base and no units.

⁦16⁩: «⁦10⁩» لە هەر واتە یەک کۆمەڵەی و هیچ یەکەیەک.

Why do programmers like hexadecimal?بۆچی بەرنامەسازەکان حەز لە شانزەیی دەکەن؟

One hex digit is exactly 4 bits, so long binary numbers become short and easy to read, and can be turned back into bits digit by digit.

یەک ڕێک 4 ، بۆیە ژمارە درێژەکان کورت و ئاسان دەبن بۆ خوێندنەوە و دەتوانرێت بە بگەڕێندرێنەوە بۆ .

How many bits do you need for 1000 different values?بۆ ⁦1000⁩ نرخی جیاواز چەند بیت پێویستە؟

10 bits: 29=5122^9 = 512 is too few and 210=10242^{10} = 1024 is enough.

⁦10⁩ : 29=5122^9 = 512 کەمە و 210=10242^{10} = 1024 بەسە.

Videoڤیدیۆ

Watch a videoسەیری ڤیدیۆیەک بکە

A video that viewers liked a lot and praised in their comments, chosen for this lesson.ڤیدیۆیەک کە بینەران زۆریان پێ خۆش بووە و لە کۆمێنتەکانیاندا ستایشیان کردووە، بۆ ئەم وانەیە هەڵبژێردراوە.

Number Systems Introduction - Decimal, Binary, Octal & HexadecimalThe Organic Chemistry Tutor · Englishئینگلیزی · 3.2M viewsبینین · 53K likesلایک · Partبەشی 0:00–3:36 (ofلە 10:57)

The decimal, binary, octal and hexadecimal systems side by side, then decimal to octal and hex by dividing again and again.

، ، و لە تەنیشت یەکتر، پاشان گۆڕینی بۆ و بە دابەشکردنی دووبارە و دووبارە.

Chapters: 0:00 decimal, 1:16 binary, 1:49 octal, 2:26 hexadecimal (digits A-F = 10-15); stops at 3:36, where it starts converting 348 to binary (next lesson's method).

بەشەکان: ⁦0:00⁩ ، ⁦1:16⁩ ، ⁦1:49⁩ ، ⁦2:26⁩ ( A تا ⁦F = 10⁩ تا ⁦15⁩)؛ لە ⁦3:36⁩ ڕادەوەستێت، کە دەست دەکات بە گۆڕینی ⁦348⁩ بۆ (ڕێگای وانەی دواتر).

Lesson complete!وانەکە تەواو بوو!

Well done. Review the key terms, then go on to the next lesson.دەستخۆش. سەیرێکی زاراوە سەرەکییەکان بکەرەوە، پاشان بڕۆ بۆ وانەی داهاتوو.

Key termsزاراوە سەرەکییەکان

Next lessonوانەی داهاتوو

From Decimal to Binary, Octal and Hexلە دەییەوە بۆ دووانی، هەشتی و شانزەیی

References and further readingسەرچاوەکان و خوێندنەوەی زیاتر

This lecture is a first edition. The Kurdish text and terminology are waiting for review by Kurdish IT teachers.ئەم وانەیە چاپی یەکەمە. دەقە کوردییەکە و زاراوەکانی چاوەڕێی پێداچوونەوەی مامۆستایانی کوردی بواری IT ن.