Skip to content

Commit a9633c0

Browse files
authored
style: include ICAST_IDIV_CAST_TO_DOUBLE (#6121)
1 parent 5ab6356 commit a9633c0

File tree

3 files changed

+3
-6
lines changed

3 files changed

+3
-6
lines changed

spotbugs-exclude.xml

-3
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,6 @@
4141
<Match>
4242
<Bug pattern="INT_BAD_REM_BY_1" />
4343
</Match>
44-
<Match>
45-
<Bug pattern="ICAST_IDIV_CAST_TO_DOUBLE" />
46-
</Match>
4744
<Match>
4845
<Bug pattern="FE_FLOATING_POINT_EQUALITY" />
4946
</Match>

src/main/java/com/thealgorithms/maths/Average.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,14 @@ public static double average(double[] numbers) {
3737
* @return the average of the given numbers
3838
* @throws IllegalArgumentException if the input array is {@code null} or empty
3939
*/
40-
public static double average(int[] numbers) {
40+
public static long average(int[] numbers) {
4141
if (numbers == null || numbers.length == 0) {
4242
throw new IllegalArgumentException("Numbers array cannot be empty or null");
4343
}
4444
long sum = 0;
4545
for (int number : numbers) {
4646
sum += number;
4747
}
48-
return (double) (sum / numbers.length);
48+
return sum / numbers.length;
4949
}
5050
}

src/main/java/com/thealgorithms/others/KochSnowflake.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ public static BufferedImage getKochSnowflake(int imageWidth, int steps) {
105105
double offsetX = imageWidth / 10.;
106106
double offsetY = imageWidth / 3.7;
107107
Vector2 vector1 = new Vector2(offsetX, offsetY);
108-
Vector2 vector2 = new Vector2(imageWidth / 2, Math.sin(Math.PI / 3) * imageWidth * 0.8 + offsetY);
108+
Vector2 vector2 = new Vector2(imageWidth / 2.0, Math.sin(Math.PI / 3.0) * imageWidth * 0.8 + offsetY);
109109
Vector2 vector3 = new Vector2(imageWidth - offsetX, offsetY);
110110
ArrayList<Vector2> initialVectors = new ArrayList<Vector2>();
111111
initialVectors.add(vector1);

0 commit comments

Comments
 (0)