Skip to content

Commit fdba1bd

Browse files
committed
explicitly used parens in place of implicit order of ops
#131
1 parent f1e83b0 commit fdba1bd

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

src/org/cicirello/math/la/MatrixOps.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
* represented as 2-D Java arrays.
2828
*
2929
* @author <a href=https://www.cicirello.org/ target=_top>Vincent A. Cicirello</a>, <a href=https://www.cicirello.org/ target=_top>https://www.cicirello.org/</a>
30-
* @version 2.13.2021
30+
* @version 5.13.2021
3131
*/
3232
public final class MatrixOps {
3333

@@ -235,7 +235,7 @@ public static double[][] difference(double[][] A, double[][] B) {
235235
* @return A reference to the C matrix.
236236
*/
237237
public static int[][] product(int[][] A, int[][] B, int[][] C) {
238-
if (A.length == 0 && B.length > 0 || A.length > 0 && B.length == 0) {
238+
if ((A.length == 0 && B.length > 0) || (A.length > 0 && B.length == 0)) {
239239
throw new IllegalArgumentException("If either matrix has 0 rows, both must.");
240240
} else if (A.length == 0) {
241241
if (C==null) return new int[0][0];
@@ -267,7 +267,7 @@ public static int[][] product(int[][] A, int[][] B, int[][] C) {
267267
* @return A reference to the C matrix.
268268
*/
269269
public static double[][] product(double[][] A, double[][] B, double[][] C) {
270-
if (A.length == 0 && B.length > 0 || A.length > 0 && B.length == 0) {
270+
if ((A.length == 0 && B.length > 0) || (A.length > 0 && B.length == 0)) {
271271
throw new IllegalArgumentException("If either matrix has 0 rows, both must.");
272272
} else if (A.length == 0) {
273273
if (C==null) return new double[0][0];

src/org/cicirello/math/rand/RandomIndexer.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
* from the motivating case, the case of efficiently generating random indexes into an array.
3434
*
3535
* @author <a href=https://www.cicirello.org/ target=_top>Vincent A. Cicirello</a>, <a href=https://www.cicirello.org/ target=_top>https://www.cicirello.org/</a>
36-
* @version 2.13.2021
36+
* @version 5.13.2021
3737
*
3838
*/
3939
public final class RandomIndexer {
@@ -152,7 +152,7 @@ public static int nextInt(int bound, Random gen) {
152152
*/
153153
public static int nextBiasedInt(int bound) {
154154
if (bound < 1) throw new IllegalArgumentException("bound must be positive");
155-
return (int)((long)(ThreadLocalRandom.current().nextInt() & 0x7fffffff) * (long)bound >> 31);
155+
return (int)(((long)(ThreadLocalRandom.current().nextInt() & 0x7fffffff) * (long)bound) >> 31);
156156
}
157157

158158
/**
@@ -178,7 +178,7 @@ public static int nextBiasedInt(int bound) {
178178
*/
179179
public static int nextBiasedInt(int bound, SplittableRandom gen) {
180180
if (bound < 1) throw new IllegalArgumentException("bound must be positive");
181-
return (int)((long)(gen.nextInt() & 0x7fffffff) * (long)bound >> 31);
181+
return (int)(((long)(gen.nextInt() & 0x7fffffff) * (long)bound) >> 31);
182182
}
183183

184184
/**
@@ -211,7 +211,7 @@ public static int nextBiasedInt(int bound, SplittableRandom gen) {
211211
*/
212212
public static int nextBiasedInt(int bound, Random gen) {
213213
if (bound < 1) throw new IllegalArgumentException("bound must be positive");
214-
return (int)((long)(gen.nextInt() & 0x7fffffff) * (long)bound >> 31);
214+
return (int)(((long)(gen.nextInt() & 0x7fffffff) * (long)bound) >> 31);
215215
}
216216

217217

src/org/cicirello/permutations/distance/KendallTauDistance.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
* M. G. Kendall, "A new measure of rank correlation," Biometrika, vol. 30, no. 1/2, pp. 81–93, June 1938.</p>
4949
*
5050
* @author <a href=https://www.cicirello.org/ target=_top>Vincent A. Cicirello</a>, <a href=https://www.cicirello.org/ target=_top>https://www.cicirello.org/</a>
51-
* @version 4.2.2021
51+
* @version 5.13.2021
5252
*
5353
*/
5454
public final class KendallTauDistance implements NormalizedPermutationDistanceMeasurer {
@@ -83,7 +83,7 @@ public int distance(Permutation p1, Permutation p2) {
8383
@Override
8484
public int max(int length) {
8585
if (length <= 1) return 0;
86-
return length*(length - 1)>>1;
86+
return (length*(length - 1))>>1;
8787
}
8888

8989
private int countInversions(int[] array) {

0 commit comments

Comments
 (0)