The Psychology of Quality and More |
CHAPTER 9 : Data Usage
9.2 Using floating point numbersFloating point variables should be explicitly kept for floating point numbers. They should never be used where an integer will suffice, as 1.0 does not necessarily equal 1. By the same token, using floating point numbers for loop variables should be avoided, as should any tests for exact value (use >= and <=):
if ( Pi != 3.14159) ------------------------------------------ float and double are analogous to short and int, in that floats are usually converted to doubles in expressions. Thus if you require limited accuracy or need to save space (eg. in arrays), then use float. Otherwise, and especially if you are unsure of the required accuracy, use double.
|
Site Menu |
Quality: | Quality Toolbook | Tools of the Trade | Improvement Encyclopedia | Quality Articles | Being Creative | Being Persuasive | |
And: | C Style (Book) | Stories | Articles | Bookstore | My Photos | About | Contact | |
Settings: | Computer layout | Mobile layout | Small font | Medium font | Large font | Translate | |
You can buy books here |
And the big |