Post date: Nov 15, 2014 9:42:45 PM
Data Types
Today, data comes in different forms including numbers, text, audio, image and video.
Bits
A bit (binary digit)is the smallest unit of data that can be stored in a computer and has a vaulue of 0 or 1.
Bit patterns
It uses to represent different types of data, so we called it string of data too.
Unsigned representation
An unsigned integer is an integer that can never b negative and can take only 0 or positive values. Hence, it has a range we called the maximum unsigned integer which has the value of 2n-1 where n is the number of bits allocated to represent an unsigned integer.
Storing unsigned integers
The integer is changed to binary. If the number of bits is less than n, 0s are added to the left of the binary integer so that there is a total of n bits, instead, the integer cannot be stored. Hence, this might occurs a condition we called overflow.
Overflow
Due to size limitations-the allocated number of bits-the range of integers that can be represented is limited. In an n-bit memory location we can only store an unsigned integer between 0 and 2n-1.
Retrieving unsigned integers
An output device retrieves a bit string from memory as a bit pattern and converts it to an unsigned decimal integer.
Sign-and-magnitude representation
In this method, the available range for unsigned integers (0 to 2n-1) is divided into two equal subranges. The first half represents positive integers, the second half, negative integers. In an n-bit allocation, we can only use n-1 bits to represent the absolute value of the number. Hence, the leftmost bit is dedicated to store the sign (0 for positive, 1 for negative).
Overflow in sign-and-magnitude representation
It might has both positive and negative overflow