Q&A
Q1: | If a short int can run out of room, why not always use long integers? |
A1: | Both short integers and long integers will run out of room, but a long integer will do so with a much larger number. However, on most machines a long integer takes up twice as much memory every time you declare one. Frankly, this is less of a problem than it used to be, because most personal computers now come with many thousands (if not millions) of bytes of memory. |
Q2: | What happens if I assign a number with a decimal to an integer rather than a
float? Consider the following line of code:
int aNumber = 5.4; |
A2: | A good compiler will issue a warning, but the assignment is completely legal. The number you've assigned will be truncated into an integer. Thus, if you ... |
Get Sams Teach Yourself C++ in 24 Hours, Third Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.