4.14 Answers to Chapter Questions

I l @ ve RuBoard

Answer 4-1: The largest number that can be stored in an int on a Unix machine is 2,147,483,647. When using an old MS-DOS compiler the limit is 32,767. The zip code 92126 is larger than 32,767, so it is mangled and the result is 26,590.

This problem can be fixed by using a long int instead of just an int . The various types of integers are discussed in Chapter 5.

Answer 4-2: The problem concerns the division: 1/3. The number 1 and the number 3 are both integers, so this is an integer divide. Fractions are truncated in an integer divide. The expression should be written as:

 answer = 1.0 / 3.0 
I l @ ve RuBoard


Practical C++ Programming
Practical C Programming, 3rd Edition
ISBN: 1565923065
EAN: 2147483647
Year: 2003
Pages: 364

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net