Skip to content

Commit

Permalink
style: include ICAST_IDIV_CAST_TO_DOUBLE (#6121)
Browse files Browse the repository at this point in the history
  • Loading branch information
vil02 authored Jan 10, 2025
1 parent 5ab6356 commit a9633c0
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 6 deletions.
3 changes: 0 additions & 3 deletions spotbugs-exclude.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,6 @@
<Match>
<Bug pattern="INT_BAD_REM_BY_1" />
</Match>
<Match>
<Bug pattern="ICAST_IDIV_CAST_TO_DOUBLE" />
</Match>
<Match>
<Bug pattern="FE_FLOATING_POINT_EQUALITY" />
</Match>
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/thealgorithms/maths/Average.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,14 @@ public static double average(double[] numbers) {
* @return the average of the given numbers
* @throws IllegalArgumentException if the input array is {@code null} or empty
*/
public static double average(int[] numbers) {
public static long average(int[] numbers) {
if (numbers == null || numbers.length == 0) {
throw new IllegalArgumentException("Numbers array cannot be empty or null");
}
long sum = 0;
for (int number : numbers) {
sum += number;
}
return (double) (sum / numbers.length);
return sum / numbers.length;
}
}
2 changes: 1 addition & 1 deletion src/main/java/com/thealgorithms/others/KochSnowflake.java
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public static BufferedImage getKochSnowflake(int imageWidth, int steps) {
double offsetX = imageWidth / 10.;
double offsetY = imageWidth / 3.7;
Vector2 vector1 = new Vector2(offsetX, offsetY);
Vector2 vector2 = new Vector2(imageWidth / 2, Math.sin(Math.PI / 3) * imageWidth * 0.8 + offsetY);
Vector2 vector2 = new Vector2(imageWidth / 2.0, Math.sin(Math.PI / 3.0) * imageWidth * 0.8 + offsetY);
Vector2 vector3 = new Vector2(imageWidth - offsetX, offsetY);
ArrayList<Vector2> initialVectors = new ArrayList<Vector2>();
initialVectors.add(vector1);
Expand Down

0 comments on commit a9633c0

Please sign in to comment.