Download presentation
Presentation is loading. Please wait.
1
Computer Science A 14: 3/4
2
Computing with numbers - Precision - Representation - Computing with numbers - Example
3
Floating point numbers Number with an integer part and decimals And very large numbers with out all digits And very small numbers near zero Ide: represent numbers as sign and two numbers sign * decimal part * 10 exponent
4
Unique representation 1*10 0 = 10*10 -1 =.. Numbers must be normalized to be on the form sign*0,decimals*10 exponent Where decimal part must not start with zero Or decimal part and exponent is zero and the number is zero
5
Float Float: 4bytes = 32 bit Exponent 8 bits: -126..127 Decimal part: 23 bits (+1) + sign Precision: 2 24 =2 10 *2 10 *2 4 ≈16.000.000 about 7 digits Interval: 2 127 ≈ 10 ? +eeeeeee 0011000100110001e0110001
6
Dobbelt præcision double: 64 bit or 8 bytes 11 bit exponent (up to 10 308 ) 52 bit decimal part (about 15 digits)
7
Cmputing with numbers Floating point numbers are nor precise. With repeated computation rounding errors may accumulate Do not compare with equality (==) but check that the difference is less than a small value. Do not subtract two almost equal values. Redesign instead the algorithm. Avoid repeated adding of numbers
8
Rounding errors If you need higher precision you need more space You need a sense of bit patterns, powers of two and knowledge of the internal representation If you need to calculate with floating point numbers be aware of the traps
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.