Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

style: include ICAST_IDIV_CAST_TO_DOUBLE #6121

Merged
merged 1 commit into from
Jan 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
}
}
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
Loading