Post date: Nov 15, 2014 9:45:43 PM
Two's complement representation
Almost all computers use this representation to store a signed integer in n n-bit memory location. In this method, the available range for an unsigned integer of (0 to 2n-1) is divided into two equal subranges. The first subrange is used to represent nonnegative integers, the second half to represent negative integers. The two halves are swapped to be an agreement with the common convention of showing negative integers to the left of positive integers.
Two operations
The first is called one's completing or taking the one's complement of an integer in binary. This operation simply reverses (flips) each bit. 0-bit and 1-bit is exchanged.
The second operation is called two's completing or taking the two's complement of an integer in binary. This operation is done in two steps, copy the bits from the right until a 1 is copied, then flip the rest of the bits.
Storing an integer in two's complement format
The integer is changed to an n-bit binary. If the integer is positive or zero, it is stored as it is, instead, the computer takes the two's complement of the integer and then stores it.
Retrieving an integer on two's complement format
If the leftmost bit is 1, the computer applies the two's complement operation to the integer. Instead, no operation is applied. Then the computer changes the integer to decimal.
Overflow in two's complement notation
Summary of integer representations (4-bit)
Audio representation
Audio is a representation of sound or music. Audio is analog data. We cannot record an infinite number of values in an interval, we can only record some samples. The number of samples depends on the maximum number of changes in the analog signal. The values measured for each sample is a real number. Quantization refers to a process that rounds up the sample values to integers.
Image representation
Storage of images is done using two different techniques, raster graphics and vector graphics. Raster graphics are used when we need to store an analog image such as photograph. The image is scanned (sampled) and pixels are stored. In the vector graphic method, an image is decomposed into a combination of geometrical shapes such as lines, squares or circles. Each geometrical shape is represented by a mathematical formula.
Video representation
Video is a representation of images (called frames) in time. A movie is series of frames shown one after another to create the illusion of continuous motion. In other words, video is the representation of information that changes in space (single image) and in time (a series of images).
Extra
Runs two's complement in C program.