Math.PI should be used instead of .1415929203539825
63
64 @Test
65 public void test11() {
66 assertEquals(3.1415929203539825d, MathInterpreter.eval("pi", Log::log));67 }
68
69 @Test
Math.E should be used instead of .7
27 throw new IllegalArgumentException(String.format("pGewicht muss unter 560 sein und über 0 sein war aber %d!", pGewicht));
28 }
29
30 if(pGroesse <= 0 || pGroesse > 2.72) {31 throw new IllegalArgumentException(String.format("pGroesse muss unter 2.72 sein und über 0 sein war aber %f!", pGroesse));
32 }
33
Description
A library constant has been redefined in source code with a different/imprecise value.
It's recommended to use the predefined library constant for code clarity and better precision.
Bad Practice
static final double PI_bad = 3.14;
double bad = 2 * PI_bad * radius;
Recommended
double good = 2 * Math.PI * radius;
References
- Spotbugs - CNT_ROUGH_CONSTANT_VALUE