< previous page page_526 next page >

Page 526
//     Function value == lowercase equivalent of ch, if ch is
//                       an uppercase letter
//                    == ch, otherwise

{
    const int DISTANCE = a - A;  // Fixed distance between
                                      // uppercase and lowercase
                                      // letters
    if (isupper(ch))
        return ch + DISTANCE;
    else
        return ch;
}
More on Floating Point Numbers
We have used floating point numbers off and on since they were introduced in Chapter 2, but we have not examined them in depth. Floating point numbers have some special properties when used on the computer. Thus far, we've almost ignored these properties, but now it's time to consider them in detail.
Representation of Floating Point Numbers
Let's assume we have a computer where each memory location is the same size and is divided into a sign plus five decimal digits. When a variable or constant is defined, the location assigned to it consists of five digits and a sign. When an int variable or constant is defined, the interpretation of the number stored in that place is quite straightforward. When a float variable or constant is defined, the number stored there has both a whole number part and a fractional part, so it must be coded to represent both parts.
Let's see what such coded numbers might look like. The range of whole numbers we can represent with five digits is -99,999 through +99,999:
0526-01.gif
Our precision (the number of digits we can represent) is five digits, and each number within that range can be represented exactly.

 
< previous page page_526 next page >