thursday 22 november 2015
play

Thursday, 22 November 2015 Please respond to the survey (see email)! - PowerPoint PPT Presentation

Thursday, 22 November 2015 Please respond to the survey (see email)! Gator Day: Tues., Nov. 27--BE THERE! 11 a.m. -- student presentations noon -- lunch Today: floating point For next week: keep reading chapter 3 Floating Point How do we


  1. Thursday, 22 November 2015 Please respond to the survey (see email)! Gator Day: Tues., Nov. 27--BE THERE! 11 a.m. -- student presentations noon -- lunch Today: floating point For next week: keep reading chapter 3

  2. Floating Point How do we represent fractional values in binary? Recall: Base 2 -- each position from right to left is a power of 2, starting with 2 0 = 1: 1001011 1x2 6 + 1x2 3 + 1x2 1 + 1x2 0 = 64 + 8 + 2 + 1 = 75

  3. Floating Point The same pattern continues to the right of the decimal point (“binary point”?): High school algebra: 2 -k = 1 1001011.01101 2 k 0x2 -1 + 1x2 -2 + 1x2 -3 + 0x2 -4 +1x2 -5 = 0 + .25 + .125 + 0 + .03125 The entire thing, in decimal, is 75.40625.

  4. Decimal Fraction to Binary Fraction To convert a decimal integer to binary, we repeatedly divided by 2 and took remainders (see notes from 17 September). To convert a decimal fraction to binary, we repeatedly multiply and take (whole number) product. Thus, .01101 .40625 x 2 = 0 .81250 (product = 0 ) .8125 x 2 = 1 .625 (product = 1 ) .625 x 2 = 1 .25 (product = 1 ) .25 x 2 = 0 .5 (product = 0 ) .5 x 2 = 1 .0 (product = 1 )

  5. Decimal to Binary Example Let’s put it all together into a single example. Convert 3.675: 3 % 2 = 1 (3/2=)1 % 2 = 1 11.101 .675 x 2 = 1 .25 (product = 1 ) .25 x 2 = 0 .5 (product = 0 ) .5 x 2 = 1 .0 (product = 1 )

  6. Scientific Notation From your high school science courses you probably are familiar with “scientific notation”: 388291.83 = 3.8829183 x 10 5 0.0003228 = 3.228 x 10 -4 3.14159 = 3.14159 x 10 0 We’ve used it already in this class, e.g., a nanosecond is .000000001 sec = 1x10 -9 sec, a megabyte is 1000000 bytes = 1x10 6 bytes.

  7. Floating Point Floating point is just scientific notation, but in binary rather than decimal. Thus, 10110.10011 = 1.011010011 x 2 4 0.0001011 = 1.011 x 2 -4 1.11001 = 1.11001 x 2 0 NOTE : You CAN NOT just translate the base 10 scientific notation into binary floating point! 5.5 x 10 0 is not 101.1 x 2 0 , but 1.011 x 2 2

  8. Floating Point Precision is the number of significant bits (or significant decimal digits--definitions vary) in a floating point number. Many fractions that have finite decimal representations have infinitely- long binary representations, so we can keep only a limited number of bits. One-tenth (0.1 ten ) is such a number: 0.1 ten = .00011001100110011001100… two

  9. 32-bit Floating Point -17 ten = 1 .0001 x 2 4 Leading “1” bit is never included ... 1 1 0 0 0 0 0 1 1 0 0 0 1 0 0 0 0 fraction sign exponent + 127 (23 bits) (1 bit) (8 bits) 4 + 127 = 10000011

  10. 32-bit Floating Point (MARS tool)

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend