binary representation

I. Bit, byte, binary, decimal and hexadecimal

>> bit and Byte

Computer systems are binary systems that use sequences of bits to represent data. A binary digit (bit) is the basic unit of information in computer systems and can have only two values: wither 1 or 0. Eight bits form a byte.

1 Byte = 8 bits

A bit is denoted by the small letter b, whereas a Byte is denoted by the capital letter B. Thus, 1B=8b.

>> decimal number system

The decimal number system is a positional system that uses ten digits (0,1,2,3,4,5,6,7,8,9,) to represent any number. The decimal number system (or base-10) has ten as its base and it is the most widely-used number system.
Since base-10 is a positional system, the position of each digit within a number provides the multiplier by which that digit is multiplied.

Figure 1: Initial place values in the decimal number system
(from CORE COMPUTER SCIENCE)

>> binary number system

The binary number system is a positional system that uses two digits (0 and 1) to represent any number.

Figure 2: initial place values in the binary number system
(from CORE COMPUTER SCIENCE)
Figure 3: convert decimal number into binary number (from CORE COMPUTER SCIENCE)

Two’s complement is the way most modern computers represent signed binary numbers. The main advantage of this representations is that addition, subtraction and multiplication are carried out easily.
suppose we want to find -28
28 in an 8-bit register is 00011100.
fist, we invert the digits, so all ones become zeros and all zeros become ones. We get 11100011.
Then we add 1, and the output is 11100100.
So this is -28 in two’s complement representation.

In binary system the radix point is used to separate the fractional from the whole part. Fixed point representation method is the method using 4 bits for the integer part and 4 bits for the fractional part.

Figure 4: binary fraction (from CORE COMPUTER SCIENCE)

The hexadecimal number system is a positional system that uses 16 digits (0,1,2,3,4,5,6,7,8,9,A,B,C,D,E and F) to represent any number. Digits A to F represent quantities from 10 to 15, thus A=10, B=11, C=12,D=13.E=14,F=15.

II. Data representation

>>Integers

We can use one byte to represent 256 different integer numbers. This would allow us to represent all the unsigned positive integers from 0 to 255.

Figure 5: positive integers (from CORE COMPUTER SCIENCE)

We can also use sign-and-magnitude number representation. The left-most bit is set to 0 for a positive number or 1 for a negative number. This allows for numbers -127 to +127 to be represented.

>>Characters

The American Standard Code for Information Interchange (ASCII) is a character-encoding scheme originally based on the English alphabet. ASCII uses 7 bits to represent each character, which means that it can achieve 128 different representations.

>>Colors

Monitors use pixels to display information and have a specific display resolution, such as 1024 x 768 has a width of 1024 pixels and a height of 768 pixels. One way to store color in pixels is the hexadecimal RGB color values. Each color value is represented by values from 00 to FF, so a six-digit hexadecimal number is need such as 70EF5A.

Figure 6: color representation (from CORE COMPUTER SCIENCE)

Leave a comment