chapter_2_and_3

advertisement
Chapter 2: Binary Values and Number Systems
2.1 Numbers and Computing
 Number a unit of an abstract mathematical systems subject to the laws of arithmetic
 Natural Number the number 0 and any number found by repeatedly adding 1 to 0
 Integer any natural or negative number (whole numbers; no decimals)
 Rational Number an integer or quotient of two integers
2.2 Positional Notation
 Base the foundational value of a number system, which dictates the number of digits and the
value of digit positions (decimal system uses base 10)
 Positional notation a system of expressing numbers in which the digits are arranged in
succession, the position of each digit has a place value, and the number is equal to the sum of
the products of each digit by its place value
 Binary, octal and hexadecimal
o Binary uses base 2, octal base 8, hexadecimal base 16
o To represent values greater than 9, we use letters (A-F)
o Numbers in a system can never be greater than the base number
 Eg. Octal uses 0-7, never anything higher
o To convert other bases to base 10, use methods discussed in class
o 0 in the rightmost position and 1 in the second position represents the value of the base
itself (i.e 10 in octal is 8 in decimal, 10 in binary is 2 in decimal)
 Arithmetic in other bases
o Refer to class notes CSE_B_arithmetic
 Power of 2 number systems
o Refer to class notes CSE_B_arithmetic
 Converting from base 10 to other bases
o Refer to class notes CSE_B_arithmetic
o Divide the decimal number by the new base, make the remainder the next digit in the
answer, replace the decimal number with the quotient
 Binary values and computers
o Computers today are binary machines
o They can only use low voltage signals or high voltage signals (0 and 1 respectively)
o Each storage location must contain either 0 or 1
o each storage unit is called a binary digit or a bit
o 8 bits create a byte, bytes created words when grouped together
o Number of bits in a word is the word length of the computer (32 or 64 bit)
Chapter 3: Data Representation
3.1 Data and Computers
 Data basic values or facts
 Information data that has been organized or processed in a useful manner
 Computers are now multimedia devices
o They deal with different data such as numbers, text, audio, images, video
 All data on a computer is represented in binary as 0s and 1s
 Data compression reducing the amount of space needed to store a piece of data
 Bandwidth the number of bits or bytes that can be transmitted from one place to another in a
fixed amount of time
 Compression ratio the size of the compressed data divided by the size of the uncompressed
data (closer the number is to 0, the tighter the compression)
 Lossless compression a data compression technique in which there is no loss of information
 Lossy compression a data compression technique in which there is loss of information
 Analog and Digital Data
o Computers are finite devices; they only have so much room to store and manipulate a
certain amount of data
o Analog dataa continuous representation of data, analogous to the actual information
it represents (ie a thermometer)
o Digital data a discrete representation of data, breaking the information up into
separate elements
o Analog data is directly proportional to the continuous, infinite world around us,
therefore computers cannot work well with analog data
o Digitize the act of breaking information down into discrete pieces
o The discrete elements are then individually represented using binary digits
o The reason to use binary systems as opposed to other number systems (ie decimal) is
because devices that store and manage binary data are less expensive and more reliable
if they only have to represent one of two possible values
o An analog signal continually fluctuates up and down in voltage. But a digital signal has
only a high or low state, corresponding to the two binary digits.
o All electronic signals (both analog and digital) degrade as they move down a line. That is,
the voltage of the signal fluctuates due to environmental effects.
o Analog signals lose information when they degrade
o Digital signals have a threshold where values above the threshold are considered high
voltage and values below are low voltage
o Periodically, digital signals are reclocked to regain its original shape, preventing loss of
data
 Binary representation
o n bits can represented 2n things because 2ncombinations of 0 and 1 can be made from n
bits
o ex. 4 bits represents 16 things, 5 bits 32
o 2 bits represent 4 things ex. 00 01 10 11
3.2 Representing Numerical Data
Representing negative values
 Signed-magnitude representation
o Number representation in which the sign represents the ordering of the number
(negative or positive) and the value represents the magnitude
o Uses the number line; positive is to the right of 0 and negative is to the left
o This creates a problem when using 0 (plus 0 or minus 0)
 We don’t consider negative 0, only positive 0
 The two representations of 0 can cause unnecessary complexity with
computers, therefore they use other representations of numbers
 Fixed-sized numbers (or complementary/tens complement) in prof notes)
o If we allow a fixed number of values, we can represent numbers as integer values where
half represent positive an half represent negative
o The sign is determined by the magnitude of the number
 Ex.0 to 49 are positive, 50 to 99 are negative (-50 to -1)
o To add, simply add numbers and discard any carry
 See CSE_B_numericdata
o Ten’s complement is represented by:
 Negative(I) = 10k – I, where k is the number of digits and I is the interger
 Two’s complement
o Arithmetic is completed similar to ten’s complement
o The leftmost bit in a negative number is always a 1
o See CSE_B_numericdata
 Number overflow
o A situation where a calculated value cannot fit into the number of digits reserved for it
o Eg stored value using 8 bits, adding 127 and 3 would produce an overflow
 01111111 + 00000011 = 10000010
 This value is -126 not +130 unless we were not representing negative numbers
o This is an example of how mapping an infinite world on a finite machine creates
problems (solutions to this problem differ by machines and computer language)
 Representing Real Numbers
o In computing, all noninteger values are real values (whole numbers with fractional
parts)
o We present numbers to the right of a decimal point as 10-1, 10-2 etc.
o In binary, we do the same thing except we use the base 2
 The decimal point is now called a radix point, since we are not using decimal
system
 Numbers to the right of radix point are 2-1, 2-2 etc.
3.3 Representing Text
 See CSE_B_text
3.4 Representing Audio Data
 Sound is perceived when a series of air compressions vibrate a membrane in our ear, sending
signals to our brain
 Stereos send an electrical signal to a speaker, which is an analog representation of the sound
wave
 To represent audio data on a computer, the analog sound wave must be digitized, breaking it
into discrete, manageable pieces
 Analog signals vary in voltage continuously
o To digitize, the voltage is measured periodically (known as sampling)
o Instead of a continuous signal, end up with a serious of numbers representing distinct
voltage levels
 To reproduce the sound, the stored voltages are used to create a new continuous signal
 The assumption is that the voltage levels change evenly between each interval, although this
does result in a loss of information (i.e peak values)




In general a sampling rate of around 40 000 times per second is enough to create a reasonable
sound
Audio formats
o Many different types that use different methods of compression
 Eg. WAV AU AIFF VQF MP3
o Currently mp3 is most popular as it offers the strongest compression ratio
MP3 Audio format
o Short for MPEG-2, audio layer 3 file
o Uses both lossy and lossless compression
o Analyzes frequency spread and human psychoacoustic models to discard information
that can’t be heard by humans
o Bit stream is compressed using a form of Huffman encoding
3.5 Representing Images and Graphics
 Representing colour
o Human eye has receptors that respond to red, blue and green
 All colours can be formed from combinations of these
o Computers use RGB (red green blue) values, which gives each colour a value from 0-255
 0 means none of that colour, 255 means full contribution of that colour
o The amount of data that is used to represent a colour is called the colour depth
 HiColor is a term that indicates a 16-bit colour depth. Five bits are used for each
number in an RGB value and the extra bit is sometimes used to represent
transparency.



TrueColor indicates a 24-bit colour depth. Therefore, each number in an RGB
value gets eight bits.
Digitized images and graphics
o Photographs are analog representations of images
 Colours are continuous and blend into one another
o To digitize the data, individual dots called picture elements (aka pixels) are created
 Each pixel is only one colour
o Number of pixels in an image is called the resolution
o If enough pixels are used (high resolution), the human eye perceives the pixels as a
continuous picture
o Raster-graphics format storing image information pixel by pixel
 Eg. Bitmap(BMP) GIF JPEG
o GIFs are popular for pictures with limited colours (only allow 256 colours) while JPEGs
are popular for photographs, as they blend colours and brightness
o All compress images in different ways (eg. Run length used for bitmap)
Vector representation of graphics
o Vector graphics representation of an image in terms of lines and shapes
 Uses a line’s direction, thickness and colour
o Allows for scaling to be done mathematically
o Small files, as every pixel does not need to be accounted for
o Not good for representing real world images
 Better for line art and cartoon style drawings
3.6 Representing Video
 A video codec (COmpressor/DECompressor) refers to the methods used to shrink the size of a
movie to allow it to be played on a computer or over a network
 Almost all video codecs use lossy compression to minimize the huge amounts of data associated
with video
 Generally 24 or 30 FPS (frames per second)
 Temporal compression movie compression technique based on differences between
consecutive frames
o When consecutive frames are similar, there is no need to record both
o A keyframe is chosen to compare differences (entire keyframe is stored)
o Best used for movies where there is little movement
 Spatial compression movie compression technique based on the same compression
techniques used for still images
o Uses pixels and run-length encoding to compress frames
Download