tutorial07

# tutorial07 - Tutorial 7 CSC1500 Computer Programming and...

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

CSC1500 Computer Principles and Programming 1 Tutorial 7 CSC1500 Computer Programming and Principles

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

View Full Document
CSC1500 Computer Principles and Programming 2 Overview Fundamental Data Types Negative integer representation IEEE floating point number representation Casting Assignment 4
CSC1500 Computer Principles and Programming 3 Unsigned integer can have only non- negative value Signed integer can have either non-negative or negative value e.g. range of 2-byte unsigned integer = [0, 2 16 - 1] = [0, 65535] e.g. range of 2-byte signed integer = [-2 15 , 2 15 - 1] = [-32768, 32767] Unsigned Integer vs. Signed Integer

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

View Full Document
CSC1500 Computer Principles and Programming 4 unsigned int a; /* range of a (in Windows platform) : 0 – 4294967295 */ int a; /* range of a (in Windows platform) : -2147483648 – 2147483647 */ Unsigned Integer vs. Signed Integer
CSC1500 Computer Principles and Programming 5 A simple approach, use one sign bit For illustration only! In computers, it is much more complicated. Example 0 111 = +7 1111 = -7 Two special cases 0 000 = 0 1 000 = -8 Range is [–8, +7] = [-2 3 , 2 3 - 1] How to store negative integers?

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

View Full Document
CSC1500 Computer Principles and Programming 6 A floating point number is stored in the following binary number format ± (1 + f ) x 2 e where 0 <= f < 1 Sign +/- Fractional part f Exponent e IEEE Floating Point Standard
CSC1500 Computer Principles and Programming 7 IEEE Floating Point Standard Single precision: 32-bit 1 sign bit 8 bit exponent (bias of 127) 23 bit fraction C language: float float value = 1.0 f ; Suffix f following a constant enforces it the float type

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

View Full Document
CSC1500 Computer Principles and Programming 8 IEEE Floating Point Standard Double precision: 64-bit 1 sign bit 11 bit exponent (bias of 1023) 52 bit fraction C language: double double value = 1.0;
CSC1500 Computer Principles and Programming 9 IEEE Floating Point Standard An example of 32-bit single precision float value = 123.5f;

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 05/23/2010 for the course COMPUTER S CSC1500 taught by Professor Fung during the Spring '10 term at CUHK.

### Page1 / 25

tutorial07 - Tutorial 7 CSC1500 Computer Programming and...

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

View Full Document
Ask a homework question - tutors are online