Another recommendation that puzzled me was using the suffix "f" when specify floats. For example, 0.0f instead of just 0.0. For the longest while, I just did it but it occured to me that perhaps I should do this for other numbers too. I looked what I should do for integers, doubles and so on.
There are only a few situations where doing this is useful. Those situations are for:
- long int, 35000L
- unsigned int, 10000U
- unsigned long, 12323UL
- floats, 1.0f
- long double, 1001.2L
See for page 55, under the topic Literals in "C++: A Beginner's Guide" by Herbert Schildt, Edition: 2, Published by McGraw-Hill Professional, 2003 for more details. The book is also available on Google Books.
No comments:
Post a Comment