...
The code uses the literal 3.14
to represent the value π. Although it removes some of the ambiguity from the literals, it complicates code maintenance. If the programmer were to decide that a more precise value of π is desired, all occurrences of 3.14
in the code would have to be found and replaced. The use of the values 2
, 3.0
, and 4.0
are not considered violations of this guideline, as they are precise values and are not represented by any other symbols in the mathematical formulas in which they are being used.
Compliant Solution (Constants)
...