mirror of
https://github.com/TheAlgorithms/Java.git
synced 2025-07-07 01:35:16 +08:00
style: include ICAST_IDIV_CAST_TO_DOUBLE
(#6121)
This commit is contained in:
@ -41,9 +41,6 @@
|
|||||||
<Match>
|
<Match>
|
||||||
<Bug pattern="INT_BAD_REM_BY_1" />
|
<Bug pattern="INT_BAD_REM_BY_1" />
|
||||||
</Match>
|
</Match>
|
||||||
<Match>
|
|
||||||
<Bug pattern="ICAST_IDIV_CAST_TO_DOUBLE" />
|
|
||||||
</Match>
|
|
||||||
<Match>
|
<Match>
|
||||||
<Bug pattern="FE_FLOATING_POINT_EQUALITY" />
|
<Bug pattern="FE_FLOATING_POINT_EQUALITY" />
|
||||||
</Match>
|
</Match>
|
||||||
|
@ -37,7 +37,7 @@ public final class Average {
|
|||||||
* @return the average of the given numbers
|
* @return the average of the given numbers
|
||||||
* @throws IllegalArgumentException if the input array is {@code null} or empty
|
* @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) {
|
if (numbers == null || numbers.length == 0) {
|
||||||
throw new IllegalArgumentException("Numbers array cannot be empty or null");
|
throw new IllegalArgumentException("Numbers array cannot be empty or null");
|
||||||
}
|
}
|
||||||
@ -45,6 +45,6 @@ public final class Average {
|
|||||||
for (int number : numbers) {
|
for (int number : numbers) {
|
||||||
sum += number;
|
sum += number;
|
||||||
}
|
}
|
||||||
return (double) (sum / numbers.length);
|
return sum / numbers.length;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -105,7 +105,7 @@ public final class KochSnowflake {
|
|||||||
double offsetX = imageWidth / 10.;
|
double offsetX = imageWidth / 10.;
|
||||||
double offsetY = imageWidth / 3.7;
|
double offsetY = imageWidth / 3.7;
|
||||||
Vector2 vector1 = new Vector2(offsetX, offsetY);
|
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);
|
Vector2 vector3 = new Vector2(imageWidth - offsetX, offsetY);
|
||||||
ArrayList<Vector2> initialVectors = new ArrayList<Vector2>();
|
ArrayList<Vector2> initialVectors = new ArrayList<Vector2>();
|
||||||
initialVectors.add(vector1);
|
initialVectors.add(vector1);
|
||||||
|
Reference in New Issue
Block a user