tutorial07 - Tutorial 7 CSC1500 Computer Programming and...

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

View Full Document Right Arrow Icon
CSC1500 Computer Principles and Programming 1 Tutorial 7 CSC1500 Computer Programming and Principles
Background image of page 1

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

View Full DocumentRight Arrow Icon
CSC1500 Computer Principles and Programming 2 Overview Fundamental Data Types Negative integer representation IEEE floating point number representation Casting Assignment 4
Background image of page 2
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
Background image of page 3

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

View Full DocumentRight Arrow Icon
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
Background image of page 4
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?
Background image of page 5

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

View Full DocumentRight Arrow Icon
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
Background image of page 6
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
Background image of page 7

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

View Full DocumentRight Arrow Icon
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;
Background image of page 8
CSC1500 Computer Principles and Programming 9 IEEE Floating Point Standard An example of 32-bit single precision float value = 123.5f;
Background image of page 9

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

View Full DocumentRight Arrow Icon
Image of page 10
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 Right Arrow Icon
Ask a homework question - tutors are online