Computer Science
Theory of Computer Science
Binary Systems
🤓 Study
📖 Quiz
Play audio lesson
Binary Systems
Understanding Binary Systems
- A Binary system is a number system that uses only two digits: 0 and 1.
- The binary system is used inside electronic computers because binary digits can be easily represented by digital electronic circuits.
- In the binary system, base is 2. This means that each digit in binary represents power of 2.
- A binary digit is called a bit. It is the fundamental unit of data in a computer system.
Binary Conversion
- Binary can be converted from/to decimal using mathematical computations.
- Binary to decimal conversion involves multiplying each binary digit by 2 raised to their specific position from right (starting from 0) and summing up all values.
- Decimal to binary involves dividing the number by 2 repeatedly until the quotient is 0. The binary value is the remainder reading from bottom up.
Binary Addition and Subtraction
- Binary addition and subtraction follow the same basic principle as in the decimal system with '0' and '1' instead of '0' through '9'.
- Addition: 0+0 = 0, 0+1 = 1, 1+0 = 1, 1+1 = 0 (with a carry 1).
- Subtraction: 1-0 = 1, 0-1 =1 (with a borrow of 1), 1-1=0, 0-0=0.
Bitwise Operations
- AND, OR, XOR and NOT are bitwise operations working on one or more bit patterns.
- Using these operations, you can manipulate data at bit level.
- A NOT operation flips the value of a bit, whereas AND, OR and XOR operations are performed on two bits at a time.
Representing Text and Images in Binary
- Text can be represented using ASCII or Unicode, converting characters into binary digits.
- Images are converted into binary using bitmap or vector graphics approaches. Bitmap represents images using pixels whereas vector uses points, lines and polygons.
Encoding Data
- Data can be encoded using methods such as parity check and checksum for error detection.
- In case of a single parity check, an additional bit is added to ensure the total number of 1-bits is even (even parity) or odd (odd parity).
- Checksum is a more advanced method that involves adding all bits together and transmitting the sum along with data for error checking.