{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Conversion

# Conversion - CSE 1400 Applied Discrete Mathematics...

This preview shows pages 1–5. Sign up to view the full content.

CSE 1400 Applied Discrete Mathematics Conversions Between Number Systems Department of Computer Sciences College of Engineering Florida Tech Fall 2011 Conversion Algorithms: Decimal to Another Base 1 Conversion of Natural Numbers 1 Conversion of Integers 3 Biased Notation for Integers 4 Conversion of Rational Numbers 5 Conversion of Floating Point Numbers 7 Problems on Converting Decimal to Another Base 7 Conversion Algorithms: Another Base to Decimal 8 Conversion of Natural Numbers 9 Conversion of Integers 10 Conversion of Rational Numbers 11 Conversion of Floating Point Numbers 11 Floating Point Arithmetic 12 Machine Epsilon 13 Problems on Converting Another Base to Decimal 14 Abstract Decimal notation using Arabic numerals is the standard system for writing numbers in everyday life. However, in many computing ap- plications, other notations are used. Chiefly: binary and hexadecimal. Learning algorithms to translate names between these numerical sys- tems forms a foundation for developing translations between more complex languages. Conversion Algorithms: Decimal to Another Base Conversion of Natural Numbers The unsigned whole numbers, the natural numbers, written in deci- mal 0, 1, 2, 3, 4, 5, . . . can be converted to binary by repeated division

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
cse 1400 applied discrete mathematics conversions between number systems 2 by 2. Dividing a number by 2 produces one of two remainders: r = 0 or r = 1. The natural numbers can be converted to hexadecimal by repeated division by 16. Dividing a number by 16 produces one of 16 remainder: r = 0 through r = 15 = F . • Convert q = 14 to binary. Repeatedly divide 14 and following quotients by 2 pushing the remainder bits onto a stack. R epeated R emaindering M od 2 Q uotients 14 7 3 1 R emainders 0 1 1 1 ( 14 ) 10 = ( 1110 ) 2 • Convert q = 14 to hexadecimal. Repeatedly divide 14 and following quotients by 16 pushing the remainder hex-digits onto a stack. R epeated R emaindering M od 16 Q uotients 14 R emainders E ( 14 ) 10 = ( E ) 16 • Convert q = 144 to binary. R epeated R emaindering M od 2 Q uotients 144 72 36 18 9 4 2 1 R emainders 0 0 0 0 1 0 0 1 ( 144 ) 10 = ( 1001 0000 ) 2 • Convert q = 144 to hexadecimal. R epeated R emaindering M od 16 Q uotients 144 9 R emainders 0 9 ( 144 ) 10 = ( 90 ) 16
cse 1400 applied discrete mathematics conversions between number systems 3 • Convert q = 143 to binary. R epeated R emaindering M od 2 Q uotients 143 71 35 17 8 4 2 1 R emainders 1 1 1 1 0 0 0 1 ( 143 ) 10 = ( 1000 1111 ) 2 • Convert q = 143 to hexadecimal. R epeated R emaindering M od 16 Q uotients 143 8 R emainders F 8 ( 143 ) 10 = ( 8 F ) 16 • Convert q = 255 to binary. R epeated R emaindering M od 2 Q uotients 255 127 63 31 15 7 3 1 R emainders 1 1 1 1 1 1 1 1 ( 255 ) 10 = ( 1111 1111 ) 2 • Convert 161 to binary. R epeated R emaindering M od 2 Q uotients 161 80 40 20 10 5 2 1 R emainders 1 0 0 0 0 1 0 1 ( 161 ) 10 = ( 1010 0001 ) 2 • Convert 161 to ternary. R epeated R emaindering M od 3 Q uotients 161 53 17 5 1 R emainders 2 2 2 2 1 ( 161 ) 10 = ( 12222 ) 3 . Notice that 161 = 1 · 3 4 + 2 · 3 3 + 2 · 3 2 + 2 · 3 1 + 2 · 3 0

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
cse 1400 applied discrete mathematics conversions between number systems 4 Conversion of Integers The signed integers can be represented in two’s complement nota- tion. To write a decimal integer
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}