Upcoming SlideShare
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Standard text messaging rates apply

# Cmp104 lec 2 number system

684

Published on

0 Likes
Statistics
Notes
• Full Name
Comment goes here.

Are you sure you want to Yes No
• Be the first to comment

• Be the first to like this

Views
Total Views
684
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
23
0
Likes
0
Embeds 0
No embeds

No notes for slide
• Ternary base 3 Quinary Base 5 Quaternary Base 4 senary numeral system is a base -6 numeral system Base - 13 , tridecimal, or tredecimal The octal numeral system ,
• ### Transcript

• 1. NUMBER SYSTEMFundamentals of Computer and programming in C (CMP 104 )
• 2. NUMBER SYSTEM POSITIONAL POSITIONAL NON-POSITIONAL NON-POSITIONAL SYSTEM SYSTEM SYSTEM SYSTEM New numbers are formed New Symbolic representation using digits: 0-9 and a for every number. decimal point. Decimal Roman 10 1 Dec. 1/10 1/100 1,2,3,4,5,6,7, I, II, III, IV, V, VI, VII, 8,9 VIII, IX 3 5 . 2 5 10 X 3×10 5×1 2×1/10 5×1/100 11 XI 30 5 .20 .05 + + 12 XII --- ----03/02/13 35 25
• 3. POSITIONAL NUMBER SYSTEM Decimal (BASE 10) Number System uses 10 symbols 0,1,2,3,4,5,6,7,8,9 called digits. Decimal numbers Integer numbers Integers are whole Real numbers numbers Numbers that has fractions Examples 1, 2, -3, 50, like 687. 345, -49.56, … 675, -560, …..03/02/13
• 4. NUMBER SYSTEM• In computer real numbers are referred to as floating point numbers.• Floating point numbers are represented as <Integer part> <Radix Point> <Fractional part> 34568 . 56735 34568.5673503/02/13
• 5. Decimal Number System In decimal number system the value of a digit is determined by digit × 10 position . In integer numbers the position is defined as 0,1,2,3,4,5,… starting from the rightmost position and moving one position at a time towards left. Position 4 3 2 1 0 10 position 10 4 10 3 10 2 10 1 10 0 Position value 10000 1000 100 10 1 Digits 7 2 1 3 4 Digit Value 7×10 4 2×10 3 1×10 2 3×10 1 4×10 003/02/13
• 6. Decimal Number System Digit Value 7×10 4 2×10 3 1×10 2 3×10 1 4×10 0 Digit Value 70000 2000 100 30 4 Integer 70000 + 2000 + 100 + 30 +4 Number 7213403/02/13
• 7. Decimal Number System In floating point numbers the position is defined as 0,1,2,3,4,5,… starting from the radix point and moving one position at a time towards left, and -1,- 2,-3, … starting from the radix point and moving towards right one position at a time.PositionPlace ValueDigits 436.85 = 4 × 100 + 3 × 10 + 6 × 1 . 8 × 0 .1 + 5 × 0.01 03/02/13
• 8. Data Representation for Computers• Computers store numeric (numbers) as well non- numeric (text, images and others) data in binary representation (binary number system).• Binary number system is a two digits (0 and 1), also referred to as bits, so it is a base 2 system.• Binary number system is also a positional number system. In this system, the position definition is same as in decimal number system.• In binary number system the value of a digit is determined by digit × 2 position .03/02/13
• 9. Binary Number System Value = digit × position 2 Position 4 3 2 1 0 2 position 24 23 22 21 20 Position value 16 8 4 2 1 Binary Digits 1 1 1 0 1 Digit Value 1×2 4 1×2 3 1×2 2 0×2 1 1×2 0 1 × 16 1×8 1×4 0×2 1×1 16 8 4 0 1 (11101)2 + = (29)1003/02/13
• 10. Binary Number System Floating Point Number (101.11)2= (5.75)10PositionPlace ValueDigits 5 7503/02/13
• 11. Can we make new number systems? Base 10 Base 2 3 4 5 6 7 8 …. --- 16 0 0 0 0 0 0 0 0 0 Binary Binary 1 1 1 1 1 1 1 1 1Decimal 2 10 2 2 2 2 2 2 2 3 11 10 3 3 3 3 3 3 4 100 11 10 4 4 4 4 Octal Octal 4 5 101 12 11 10 5 5 5 5 6 110 20 12 11 10 6 6 6 7 111 21 13 12 11 10 7 7 8 1000 22 20 13 12 11 10 8 9 1001 100 21 14 13 12 11 9 10 1010 101 22 20 14 13 12 A 11 1011 102 23 21 15 14 13 B Hexadecimal Relationship 12 1100 110 30 22 20 15 14 C 13 1101 111 31 23 21 16 15 D 14 1110 112 32 24 22 20 16 E 15 1111 120 33 30 23 21 17 F03/02/13
• 12. Decimal, Binary, Octal and Hexdecimal (1101)2 = 1 x 23+1x22+0x21+1x20 l = 1 x 8+ 1 x 4 + 0 x 2 + 1 x 1 ecima = 8+4+0+1 tod ary = (13)10 Bin (2057)8 = 2 x 83+0x82+5x81+7x80 l = 2 x 512+ 0 x 64 + 5 x 8 + 7 x 1 ecima d = 1024+0+40+7 l to Octa = (1071)10 l a (1AF)16 = 1 x 162+Ax161+Fx160 e cim = 1 x 256+ 10 x 16 + 15 x 1 tod m al = 256+160+15 deci = (431)10 H exa03/02/13
• 13. More examplesTernary (base-3) numbers (211)3 = 2 x 32 + 1 x 31 + 1 x 30Quaternary (base-4) numbers =18 + 3+1Quinary (base-5) numbers = (22)10 (211)4 = 2 x 42 + 1 x 41 + 1 x 40Senary (base-6 ) numbers =32 + 4+1?? (base-7) numbers = (37)10Tridecimal or Tredecimal(base-13) numbers (211)5 = 2 x 52 + 1 x 51 + 1 x 50 =50 + 5+1Mayan number (base-20) system = (56)10 Ex. (211)6 = (?)10 (211)7 = (?)10 (211)13 = (?)1003/02/13 (211)20= (?)10
• 14. From Decimal to Another Base1. Divide the decimal Example number by the new base. Convert (25)10=()22. Record the remainder as the right most digit.3. Divide the quotient of the previous divide by the new Number/ Quotient Reminder base. Base4. Record the remainder as 25/2 12 1 the next digit. 12/2 6 05. Repeat step 3& 4 until the quotient becomes 0 in 6/2 3 0 step 3. 3/2 1 1 1/2 0 103/02/13 (25)10=(11001)2
• 15. From Decimal to Another Base Convert Convert (42)10=()2 (952)10=()8 2 42 Remainder 8 952 Remainder 21 0 119 0 10 1 14 7 5 0 1 6 2 1 0 1 1 0 0 1 Convert (952)10=(1670)8 Convert (42)10=(101010)203/02/13
• 16. From Decimal to Another Base Convert Convert (428)10=()16 (100)10=()5 16 428 Remainder 5 100 Remainder 26 12 C 20 0 1 10 A 4 0 0 1 0 4 Convert Convert (428)10=(1AC)16 (100)10=(400)503/02/13
• 17. From Decimal to Another Base Convert Convert (100)10=()4 (1715)10=()12 4 100 Remainder 1 1715 Remainder 25 0 2 142 11 B 6 1 11 10 A 1 2 0 11 B 0 1 Convert Convert (100)10=(1210)4 (1715)10=(BAB)1203/02/13
• 18. Converting from a base other than to a base other than 10 1. Convert the original number to a decimal number. 2. Convert that decimal number to the new base. Convert (545)6 to () 4 (545)6 = 5 x 62+4 x 61+ 5 x 60 = 5 x 36 + 4 x 6 + 5 x 1 = 180+24+5= (209)10 4 209 Remainder 52 1 13 0 545)6 = (209)10=(3101) 4 3 1 0 303/02/13
• 19. Converting form a base other than to a base other than 10 Convert (101110)2 to () 8 (101110)2 = 1 x 25+0 x 24+1 x 23 +1 x 22+1 x 21+0 x 20 = (46)10 8 46 Remainder 5 6 (101110)2 = (46)10=(56)8 0 5 Convert (11010011)2 to () 16 (11010011)2 = 1 x 27+1 x 26+0 x 25 +1 x 24+0 x 23 +0 x 22+1 x 21+1 x 20 = (211)10 1 211 Remainder 6 13 3 3 (11010011)2 = (211)10=D3) 16 0 13 D03/02/13
• 20. Shortcut methods Binary to Octal 1.Start from the rightmost position, make groups of three binary digits. 2.Convert each group into octal digit Convert (101110)2 to () 8 101 110 (5 6)8 Octal to Binary 1.Convert each octal to three digit binary. 2.Combine them in a single binary number (5 6)803/02/13 (101 110)2
• 21. Shortcut methods Convert (562) 8 to ()2 5 6 2 101 110 010 Convert (6751) 8 to ()2 6 7 5 1 110 111 101 00103/02/13
• 22. Shortcut methods Binary to Hexadecimal conversion 1.Starting from the right most position make groups of 4 binary digits 2.Convert each group its hexadecimal equivalent digits (0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F Convert (10 1110 0000 1000)2 to () 16 10 1110 0000 1000 (2) (14) (0) (8) (2E08) 1603/02/13
• 23. Shortcut methods Hexadecimal to Binary conversion 1.Convert each hexadecimal digit 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F into 4 binary digit. Convert (1EBA2F ) 16 (1) (E) (B) (2) (F) 0001 1110 1011 0010 111103/02/13
• 24. Floating Point 368.65368.65 x 10-1 = 36.865 368.65 x 101 = 3686.5368.65 x 10-2 = 3.6865 368.65 x 102 = 36865.368.65 x 10-3 = .36865 .36865 x 103 36865. x 10-203/02/13 Mantissa Exponent