To explain this strange behavior of the program we

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 2,147,483,648. To explain this strange behavior of the program, we must remember that the memories of computers can contain only non-negative binary numbers. Negative numbers are represented so that some positive values stored in memory are considered as negative numbers. For example, the value 2,147,483,648 is treated as -2,147,483,648. The values that can be contained in 4-byte int variables have the following meanings: VALUE IN MEMORY MEANING IN PROGRAM 2,147,483,648 2,147,483,649 2,147,483,650 . . 4,294,967,294 4,294,967,295 0 1 . . 2,147,483,646 2,147,483,647 -2,147,483,648 -2,147,483,647 -2,147,483,646 . . -2 -1 0 1 . . 2,147,483,646 2,147,483,647 (80000000H) (80000001H) (80000002H) (FFFFFFFEH) (FFFFFFFFH) (7FFFFFFEH) (7FFFFFFFH) Figure 5-1 shows how the variables of program look like in the main memory of a computer, and how the values of the variables change when the program is executed with input value 1234. A variable declaration like int integer_from_keyboard ; reserves four bytes from contiguous memory locations somewhere in the main m...
View Full Document

{[ snackBarMessage ]}

Ask a homework question - tutors are online