BME303_lecture4_chap2

# BME303_lecture4_chap2 - BME303 Intro to Computing Chapter 2...

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

1 BME303 Intro. to Computing Chapter 2 – cont’d BME303 Intro. to Computing 2 Hexadecimal? 0001001010101011 0x 12AB – a convenient way to represent binary strings 0001 0010 1010 1011 12 A B

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

View Full Document
2 BME303 Intro. to Computing 3 Hexadecimal? 0001 0010 1010 1011 12 A B Decimal value = ? http://easycalculation.com/hex-converter.php BME303 Intro. to Computing 4 D6 b 7 b 6 b 5 b 4 b 3 b 2 b 1 b 0 1 1010110 Working with long strings of 1s and 0s is difficult We use hexadecimal (or hex) notation as a form of shorthand 1101 0110 = 0x D 6 = # ??? Hex is a 16-base number system How to convert to/from hex? hint: use binary as middle-man What about sign? Hexadecimal Notation
3 BME303 Intro. to Computing 5 Hexadecimal Numbers Convert binary 0011011011010101 to hex 0x36D5 0011 0110 1101 0101 3 6 D 5 Binary Hex 0000 0 0001 1 0010 2 0011 3 0100 4 0101 5 0110 6 0111 7 1000 8 1001 9 1010 A 1011 B 1100 C 1101 D 1110 E 1111 F 1001101100000111 0011101100000111 1101111000101111 1011111011101111 BME303 Intro. to Computing 6 Floating Point: Fractions Decimal Binary #3.5 11.1 b

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

View Full Document
4 BME303 Intro. to Computing Floating Point: Fractions • Decimal: 2.010 · 10 3 = 2010 • Binary: 1.0011· 2 2 = 100.11 7 BME303 Intro. to Computing 8 10 2 10 1 10 0 10 -1 10 -2 10 -3 100 10 1 1/10 1/100 1/1000 2 2 2 1 2 0 2 -1 2 -2 2 -3 4 2 1 1/2 1/4 1/8 = #3.50 Floating Point: Fractions Decimal Binary #3.5, 4.75, 5.25 ??? = #4.75 = #5.25 = #3.50 = #4.75 = #5.25
5 BME303 Intro. to Computing 9 Floating Point Computers represent real numbers using Floating Point notations Decimal: 2010 = 2.010 · 10 3 Binary: 100.11 = 1.0011· 2 2 IEEE Standard : ( 1 ) S ·1. fraction ·2 exponent 127 (1 exponent 254) S exponent (8-bit) fraction (23-bit) 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 5 2 1 0 32 bits total; exponent is an unsigned 8-bit integer BME303 Intro. to Computing 10 Floating Point Three step process: - convert the decimal number to a binary number - write binary number in “normalized” scientific notation - find the exponential term - store the number in the proper format ( 1 ) S ·1. fraction ·2 exponent 127 (1 exponent 254) S exponent (8-bit) fraction (23-bit) 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 5 2 1 0 IEEE Standard for Floating Point Arithmetic (“rules”)

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

View Full Document
6 BME303 Intro. to Computing 11 Floating Point: Example 1 01111110 10000000000000000000000b – Sign is 1 , meaning the number is negative – Exponent field is 01111110 = 126 (decimal) – Fraction is . 100000000000 1. 1 ·2 ( 126 -127) b= 1. 1 -1 b= 0.11 b= 0.75 ( 1 ) S ·1. fraction ·2 exponent 127 (1 exponent 254) BME303 Intro. to Computing •0 10000000 00000000000000000000000 = +1 * 2**( -127) * 1.0 = 2 10000001 10100000000000000000000 = * 2**(129-127) * 1. = •1 10000001 10100000000000000000000 = 12 ( 1 ) S ·1. fraction ·2 exponent 127 (1 exponent 254)
7 BME303 Intro. to Computing 13 •When exponent field is 00000000 and fraction is 0, the value is +/- 0 (depending on the sign bit) •When exponent field is 00000000 and fraction is not 0, use this formula instead: ( 1) S · 0 .fraction·2 -126 •When exponent field is 11111111 and fraction is 0, the value is +/- inf •When exponent field is 11111111 and fraction is not 0, the value is NaN (not a number) Question: What is the smallest non-negative, non-zero number that can be represented in IEEE 754 floating point format?

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

## This note was uploaded on 02/02/2011 for the course BME 303 taught by Professor Ren during the Spring '08 term at University of Texas.

### Page1 / 24

BME303_lecture4_chap2 - BME303 Intro to Computing Chapter 2...

This preview shows document pages 1 - 8. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online