[SOLVED] CS UTF-32, UTF-16, UTF-8, and UTF-7. The numbers indicate the number of bits i

$25

File Name: CS_UTF-32,_UTF-16,_UTF-8,_and_UTF-7._The_numbers_indicate_the_number_of_bits_i.zip
File Size: 734.76 KB

5/5 - (1 vote)

1007ICT / 1807ICT / 7611ICT Computer Systems & Networks
2B. Data Representation

Last Lecture

Copyright By Assignmentchef assignmentchef

Computerdata
Representingbinaryintegers
Convertingfrombinarytodecimal
Powersindifferentbases
Integerwordsizes
Convertingfromdecimaltobinary
Hexadecimalandoctalrepresentations
. Revised and updated by,, and Wee Lum 2

This Lectures Content
Learningobjectives
Binaryaddition
Representingnegativenumbers
OnescomplementandTwoscomplement
Representingcharacterdata,images,andaudio
. Revised and updated by,, and Wee Lum 3

Learning Objectives
At the end of this lecture you will have:
Learnt how to perform binary addition
Learnt how to represent negative numbers in binary
Learnt how to apply Ones complement and Twos complement
Gained an understanding of how character data, images, and audio are represented digitally
. Revised and updated by,, and Wee Lum 4

Binary Addition
How do we add up binary numbers?
We add up each binary place and take any
carry over into the next column.
EG: Single Bit Addition
0011A 0 1 0 1B+ 0 1 1 10
EG: Multiple Bit Addition
0111 0011 1100 0111
1001 A 0110 B+
0010 0100 0110
10011 1010 1111 . Revised and updated by,, and Wee Lum 5

Negative Integers (Section 4.2)
Sofarwehaveonlydealtwithpositiveintegers.
Weneedsomewayofrepresentingthesigns(+or-).
Wecouldtrymakingthemostsignificantbitinaword 0 for positive numbers and 1 for negative numbers.
Sign 0 = +ve 1= -ve
+2 = 0 0000010 -2 = 1 0000010
+127 = 0 1111111 -127 = 1 1111111
. Revised and updated by,, and Wee Lum 6

Negative Integers
Sign 0 = +ve 1= -ve
. Revised and updated by,, and Wee Lum 7

Negative Integers
A problem with this approach, there are two zeroes:
+0 = 0 0000000 -0 = 1 0000000
Sign 0 = +ve 1= -ve
. Revised and updated by,, and Wee Lum 8

Negative Integers
B C is equivalent to B + (-C)
Letstrytoadd+7to5withbinaryadditionandusing the most significant bit as the sign bit
Thisdoesnotwork.Weneedsomeotherwayof representing negative numbers so addition works
+7 0 0000111 -5 1 0000101
+2 1 0001100 = -12!
. Revised and updated by,, and Wee Lum 9
Sign 0 = +ve 1= -ve

Ones Complement
Usingasignbitplusbinarymagnitudedoesnotwork.
Letstryusingasignbitplusthebitwisecomplementof
the magnitude.
Thecomplementofabinaryvalueisdefinedasfollows:
Complement
Wecancomplementabinarynumberby complementing each of its bits (change all the 1s to 0s and all the 0s to 1s)
Eg: Binary value: 1000111 Complement: 0111000
. Revised and updated by,, and Wee Lum 10

Ones Complement
Usingasignbitplusbinarymagnitudedoesnotwork.
Letstryusingasignbitplusthebitwisecomplement of the magnitude.
+2 = 0 0000010 -2 = 1 1111101
+127 = 0 1111111 -127 = 1 0000000
+0 = 0 0000000 -0 = 1 1111111
Nowletstrytoaddsomenumberslikebefore
-4 1 1111011
+6 0 0000110
+2 (1)0 0000001 = +1!
-3 1 1111100
-2 1 1111101
-5 (1)1 1111001 = -6!
Carry Bit (ignored)
Stillwrongbutcloserweareonlyoutby1.
Thecluetowhatiswrongisduetohaving2zeros . Revised and updated by,, and Wee Lum 11

Twos Complement (Approach 1)
Letstryonescomplement+1fornegativenumbers (this is called Twos complement)
+6=00000110 +2=00000010 -2=11111110 +5=00000101 +1=00000001 -3=11111101 +4=00000100 0=00000000 -4=11111100 +3=00000011 -1=11111111 -5=11111011
Nowletstrytoaddsomenumberslikebefore
+7 0 0000111
-5 1 1111011
+2 (1)0 0000010 = +2
-3 1 1111101
-2 1 1111110
-5 (1)1 1111011 = -5
+3 0 0000011
-5 1 1111011
-2 (1)1 1111110 = -2
This works!
. Revised and updated by,, and Wee Lum 12

Twos Complement (Approach 2)
Thereisanalternative(simpler)methodtoobtainthe Twos complement for a number
Theapproachisasfollows:
1. Start from the right hand side of the binary number
2. For all bits to the left of the first 1
2.1. Change all 1s to 0s and all 0s to 1s
First 1 from the right hand-side
Values in red have been changed in Step 2.1.
. Revised and updated by,, and Wee Lum 13

Number Representations
Numbersarestoredasawordsizedsetofbits.
Itispossibletousebothsmallerandlargerwords
sizes to represent numbers of different ranges.
Someprogramminglanguages(likeC)mightusethe following unsigned and signed data types on a 32 bit word size architecture:
unsigned char
unsigned int
0 .. 65535
unsigned long int
0 .. 4,294,967,296
-128.. +127
-32768 ..+32767
-2147483648 .. +2147483647
. Revised and updated by,, and Wee Lum 14

I/O Data Types and Encoding
I/O devices need to represent a wide range of different data types
Keyboard presses
On screen text display
Bitmapped Images and Graphics Audio, Video
A processor needs to be able to process all of these different types
Hence each of these data types has its own internal binary representation
. Revised and updated by,, and Wee Lum 15

Character Data (Section 4.4)
Keyboard input consists of a series of individual characters
Onscreen text display also consists of characters
Each character is represented using an 8 bit code that is defined by the ASCII standard
We can represent a string of characters using a string of hexadecimal words:1007GC = 31 30 30 37 47 43
. Revised and updated by,, and Wee Lum 16

ASCII Table
A = 0x41
. Revised and updated by,, and Wee Lum 17

Character Data
Thereareotherstandardsforrepresentingcharacters. EBCDIC
The EBCDIC (Extended Binary Coded Decimal Interchange Code) is another 8 bit format introduced by IBM.
Unicode uses different sized codewords to represent many 1000s of
different characters to support a wide number of foreign languages.
The first 128 characters in Unicode are identical to ASCII.
There are several mapping (char to number) methods specified in Unicode: UTF-32, UTF-16, UTF-8, and UTF-7. The numbers indicate the number of bits in one codeword. In some cases a variable number of codewords can be used to represent each character.
Unicode is used in operating systems such as Windows 2000/XP, and in some compilers such as Java (a char in Java is 16 bits).
. Revised and updated by,, and Wee Lum 18

Bitmap Images
A bitmap image is just a 2D array of unsigned numbers where each element specifies the colour at that location.
The number of bits used to represent each pixel defines the number of colour shades that the bitmap can contain
Each individual element in the array is called a
A computer display is basically just a large bitmap
1 bit Image 12 x 10 pixels
4 bit Image 12 x 10 pixels
12 bits wide
48 bits wide
. Revised and updated by,, and Wee Lum Tan
0 = black 1 = white
0 = black F = white

Colour Formats
Colour bitmaps can be represented in various ways depending on the colour resolution of the output device
The bit depth (N) determines the number of colours that can be simultaneously displayed on the screen = 2N
Bitmaps use a single bit to represent each pixel (ON / OFF).
GreyScale uses up to 8 bits/pixel to generate output from black (0) to white (255).
Colour mapped uses 8 bits for each pixel as an index into a 24-bit colour (RGB) lookup table to display up to 256 colours (restricted version of True Colour)
True Colour uses 24-bits / pixel to represent the 3 primary colour components (R,G,B) using 8 bits each. May use 5 bits per component (15/16 bit colour).
Black(0,0,0), White (255,255,255), Red(255,0,0), Blue(0,0,255) etc
Some formats may use BGR instead of RGB
Some formats use 32bits to support an additional alpha channel that specifies transparency for each pixel as well as the RGB colour.
. Revised and updated by,, and Wee Lum 20

Audio and Sounds
Waveform Audio file format is simply a digitised audio sound wave.
Analogue audio is captured using a microphone and converted to digital in the sound card and stored as PCM.
Analogue to Digital conversion first takes discrete samples or snapshots of the value of the sound wave in time and then quantises (or converts) the value of each sample into an unsigned number using a determined wordsize.
The resulting representation is an array of unsigned words and is called Pulse Code Modulation (PCM)
8-bitExample:8060404020202040406080A0C0COE0E0E0 E0
Sound wave
60 sampled 40
. Revised and updated by,, and Wee Lum 21

Have considered:
Binary number operations
Ones complement and twos complement
Representing characters, images and audio
. Revised and updated by,, and Wee Lum 22

Digital Logic
. Revised and updated by,, and Wee Lum 23

CS: assignmentchef QQ: 1823890830 Email: [email protected]

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[SOLVED] CS UTF-32, UTF-16, UTF-8, and UTF-7. The numbers indicate the number of bits i
$25