Download presentation
Presentation is loading. Please wait.
Published byBeatrix Cain Modified over 9 years ago
1
Data Representation, Number Systems and Base Conversions
Computer Orgn & Arch 2011
2
Chapter Outline Numeric data representation systems
Binary, octal, and hexadecimal Non-numeric data representation ASCII and EBCDIC, UNICODE Representation of numbers Integers, floating point and Binary coded decimal Number base conversions Computer Orgn & Arch 2011
3
Number systems and computers
The BINARY number system is a positional number system with similar properties to the decimal system. However, we often need to convert binary to a number system we are familiar with (decimal) or a system that is easier for humans to use. Computer programs and data are often represented using octal and hexadecimal number systems because they are a short hand way of representing binary numbers. Computer Orgn & Arch 2011
4
Binary presentation of data
Sometimes binary numbers need to be converted to Hexadecimal (hex) numbers which reduces a long string of binary digits to a few hexadecimal characters. This makes it easier to remember and to work with the numbers. Computer Orgn & Arch 2011
5
Numeric Data representation
Deals with the representation of numbers in a computer. In digital computers, the most commonly used number systems are: binary octal hexadecimal Number System Radix (base) Digits used Decimal , 1, .....,9 Binary , 1 Octal , 1, , 7 Hexadecimal , 1, ..., 9, A, B, ..., Computer Orgn & Arch 2011
6
There are three Numbers formats in computer world.
Integer or fixed point format Floating point format Binary Coded Decimal format (BCD) Computer Orgn & Arch 2011
7
Numeric Data representation
Numeric data can be Integers - fixed-point numbers (no fractional part) Unsigned integers. the standard binary encoding already given. Supports only positive values Signed Magnitude integers. This is another way or representing negative integers. Involves treating the most significant (left most) bit in the word as a sign bit Positive-0, negative example: 4 bits, is 5 & is -5 Floating-point numbers - numbers with fractional components Computer Orgn & Arch 2011
8
Binary Coded Decimal When data is entered , it must be converted into some binary form before processing can begin. This is called BCD In BCD, each figure of the number to be coded is represented by its 4 bits binary equivalent Example 8159=
9
There are two BCD formats; Packed(condensed) and Extended(unpacked)
Computer Orgn & Arch 2011
10
Formats Packed, each figure occupies half a byte. Eg 341= Unpacked, each decimal figure is represented by a byte. Eg 341= Hardware designed for BCD is more complex than that for binary formats Advantage, its closer to the alphanumeric codes.
11
Number Base Conversions
Two techniques available: Repeated division Bit grouping Computer Orgn & Arch 2011
12
Number Base Conversions (Cont)
Repeated Division Technique To convert a number in base to the equivalent number in base , divide the given number by base using base arithmetic. Computer Orgn & Arch 2011
13
Number Base Conversions (Cont)
Bit Grouping Technique Employed for conversion between octal and binary and for the conversion between hexadecimal and binary. Each hexadecimal digit corresponds to a group of four binary bits. Each octal digit corresponds to a group of three binary bits. Computer Orgn & Arch 2011
14
Number Base Conversions (Cont)
Binary to Octal and Octal to Binary To convert a binary number to octal, simply split up the binary number into 3-bit groups starting from the least significant bit and get the corresponding octal digits. Qn . Convert to octal . to octal To convert an octal number to binary, for each octal digit, get the equivalent 3-bit binary representation. Computer Orgn & Arch 2011
15
Number Systems - Hexadecimal
The hexadecimal system is a base-16 system. It contains the digits 0 to 9 and the letters A to F. The letters A to F represent the decimal numbers 10 to 15. Decimal Hexadecimal 0,1,2…9 0,1,2…..9 10 A 11 B 12 C 13 D 14 E 15 F Computer Orgn & Arch 2011
16
Number Systems - Hexadecimal
Conversion to binary is done the same way as octal to binary, but binary digits are organized into groups of 4. Conversion from binary to hexadecimal involves breaking the bits into groups of 4 and replacing them with the hexadecimal equivalent. Computer Orgn & Arch 2011
17
Hexadecimal - Binary conversions
A B C D E F Hex to binary: (Bit group repeating) 1D7F16 = 5AB216 = Binary to hex: = E30C16 = 98DF16 Computer Orgn & Arch 2011
18
Number Base Conversions (Cont)
Binary to hex and hex to binary To convert a binary number to hexadecimal, simply split up the binary number into 4-bit groups starting from the least significant bit and get the corresponding hexadecimal digits. Qn. Convert to Hex. To convert a hexadecimal number to binary, for each hexadecimal digit, get the equivalent 4-bit binary representation. Computer Orgn & Arch 2011
19
Number Systems - Octal An octal number can easily be converted to binary by replacing each octal digit with the corresponding group of 3 binary digits. Octal Binary Computer Orgn & Arch 2011
20
Data representation Human brain can process large variety of data including: characters numbers images and sounds touch, smell and taste Current technology limits data that computer can efficiently manipulate to numeric data. Therefore, ALL data - no matter how complex - must be represented (encoded) in the computers memory in numeric form. Computer Orgn & Arch 2011
21
Data Representation Computers represent data using binary numbers because: It is easy to represent binary numbers as electrical states or signals which can be processed by two-state (on-off) electrical devices (eg transistors) . Standardization; organizations have created standard data encoding methods for communication among computer systems and their components. Computer Orgn & Arch 2011
22
Number Systems - Decimal
The decimal system is a base-10 system. There are 10 distinct digits (0 to 9) used to represent any quantity. For an n-digit number, the value that each digit represents depends on its weight or position. The weights are based on powers of 10. 4TH. 3RD. 2ND. 1ST. POSITION 103 = 1000 102 = 100 101 = 10 100 = 1 WEIGHT For example, = 4* * *10 +6*1 Computer Orgn & Arch 2011
23
Base 10 number systems Base 10 uses the ten symbols 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9 which are combined to represent all possible numeric values. The decimal number system is based on powers of 10. Each column position of a value, from right to left, is multiplied by the number 10, which is the base number, raised to a power, which is the exponent. The power that 10 is raised to depends on its position to the left of the decimal point. Computer Orgn & Arch 2011
24
Number Systems - Binary
The binary system is a base-2 system. There are 2 distinct digits (0 and 1) to represent any quantity. For an n-digit number, the value that each digit represents depends on its weight or position. The weights are based on powers of 2. 8TH TH TH TH TH RD ND ST POSITION 27= = = = = = = =1 WEIGHT For example: = 1* *64 + 0*32 + 1*16 + 0*8 + 0*4 + 1*2 +0*1 = 21010 Computer Orgn & Arch 2011
25
Converting decimal numbers to 8-bit binary numbers
Example: Convert the binary number to a decimal number. Note: Work from right to left. Remember that anything raised to the 0 power is 1. Therefore 20 = 1 0 x 20 = 0 0 x 21 = 0 0 x 22 = 0 0 x 23 = 0 1 x 24 = 16 1 x 25 = 32 1 x 26 = 64 + 0 x 27= 0 ––––––––––– 112 Computer Orgn & Arch 2011
26
Number Systems - Octal Octal and hexadecimal systems provide a shorthand way to deal with the long strings of 1’s and 0’s in binary. Octal is a base-8 system using the digits 0 to 7. To convert to decimal, you can again use a weighted system eg. 75128 = 7*83 + 5*82 + 1*81 + 2*80 = To convert to decimal, you can again use a weighted system = ? Computer Orgn & Arch 2011
27
Decimal to Base-n Conversions
To convert from decimal to a different number base such as octal, binary or hexadecimal involves repeated division by that number base. Keep dividing until the quotient is zero Use the remainders in reverse order Computer Orgn & Arch 2011
28
Decimal to Base-n Conversions
Decimal to Octal Decimal to Hex 8 | |735 8 |84 2 (*80) |45 F (*160) 8 |10 4 (*81) | 2 D (*161) 8 | 1 2 (*82) | 0 2 (*162) 8 | 0 1 (*83) Answer: Answer: 2DF16 Computer Orgn & Arch 2011
29
Computer Orgn & Arch 2011
30
Adding numbers So to add the numbers 0610=01102 and 0710=01112 (answer=1310=11012) we can write out the calculation Decimal Unsigned Binary (carry) (carry) Computer Orgn & Arch 2011
31
Multiplying number Decimal Binary
For example, × = 0 0 1 0 1 0 0 1 = 41 (base10) × 0 0 0 0 0 1 1 0 = (base 10) 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 1 0 0 1 0 1 0 0 1 0 0 1 1 1 1 0 1 1 0 = 246 (base 10) Computer Orgn & Arch 2011
32
Rules of Binary Subtraction = = 1, and borrow 1 from the next more significant bit = = 0 For example, = 0 borrows 0 0 1 10 0 1 0 1 =37 (base10) - 0 0 0 1 0 0 0 1 =17 (base 10) 0 0 0 1 0 1 0 0 =20 (base10) Computer Orgn & Arch 2011
33
Non-numeric Data Representation
Alphanumeric codes are used when the computing device has to handle letters and special symbols as well as decimal digits. Two dominant coding schemes are: ASCII (American Standard Code for Information Interchange) EBCDIC (Extended Binary Coded decimal Interchange Code) Computer Orgn & Arch 2011
34
Alphanumeric Codes There are three main coding methods in use:
The American Standard Code for Information Interchange (ASCII) Extended Binary Coded Decimal Interchange Code (EBCDIC) Unicode. Computer Orgn & Arch 2011
35
Alphanumeric Data Alphanumeric (character) data such as names and addresses are represented by assigning a unique binary code or sequence of bits to represent each character. As each character is entered from a keyboard (or other input device) it is converted into its binary code. Computer Orgn & Arch 2011
36
Alphanumeric Data Character code sets contain two classes of codes:
Printable (normal characters) Non-printable ie. characters used as control codes. For example: CTRL G CTRL Z . Most computers use ASCII codes to represent text, which makes it possible to transfer data from one computer to another. ASCII (128 characters) Computer Orgn & Arch 2011
37
ASCII ASCII 7-bit code (128 characters) has an extended 8-bit version
used on PC’s and non-IBM mainframes Was widely used to transfer data from one computer to another – now being replaced by Unicode Computer Orgn & Arch 2011
38
ASCII ASCII is a code for representing English characters as numbers, with each letter assigned a number from 0 to 127. Each character has a unique pattern of eight binary digits assigned to represent it. Computer Orgn & Arch 2011
39
ASCII Coding Examples An ASCII subset “CAB” = 43414216
F Symbol Code “CAB” = = “F1” = = “3415” = = *Note that this is a text string and no arithmetic may be done on it. A postcode is a good example of storing numbers as text. Computer Orgn & Arch 2011
40
Alphanumeric Codes EBCDIC
an 8-bit code (256 characters) used on mainframe IBM machines. The binary code for text as well as communications and printer control from IBM Both ASCII and EBCDIC are inadequate for representing all international characters. eg Chinese characters Computer Orgn & Arch 2011
41
Alphanumeric Codes Unicode - recent 16 bit standard - can represent 65 thousand characters, of which 49,000 have been defined, incorporates ASCII-7 as subset. Computer Orgn & Arch 2011
42
Both of those are 1 byte per character
Both of those are 1 byte per character. ( ASCII & EBCDIC) Unicode is a coding where characters require 2 bytes per character. Windows can use unicode, but it is not required. It is useful if extra characters not supported in the 1 byte character sets are needed in the same document. Computer Orgn & Arch 2011
43
Representing Images Two popular techniques used
Bitmap techniques . image composed of pixels is known as a bitmapped image Vector techniques. Vector graphics is the use of geometrical primitives such as points, lines, curves, and shapes or polygon(s), which are all based on mathematical equations, to represent images in computer graphics. Computer Orgn & Arch 2011
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.