Skip to content

Commit

Permalink
Fix Violations, make PMD stop complaining
Browse files Browse the repository at this point in the history
  • Loading branch information
IThundxr committed Feb 17, 2024
1 parent e826f79 commit e78fa4f
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 28 deletions.
32 changes: 16 additions & 16 deletions src/main/java/net/jafama/CmnFastMath.java
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ static final class MyTSinCos {
static {
init();
}
private static strictfp void init() {
private static void init() {
final int SIN_COS_PI_INDEX = (SIN_COS_TABS_SIZE-1)/2;
final int SIN_COS_PI_MUL_2_INDEX = 2*SIN_COS_PI_INDEX;
final int SIN_COS_PI_MUL_0_5_INDEX = SIN_COS_PI_INDEX/2;
Expand Down Expand Up @@ -409,7 +409,7 @@ static final class MyTTan {
static {
init();
}
private static strictfp void init() {
private static void init() {
for (int i=0;i<TAN_TABS_SIZE;i++) {
// angle: in [0,TAN_MAX_VALUE_FOR_TABS].
double angle = i * TAN_DELTA_HI + i * TAN_DELTA_LO;
Expand Down Expand Up @@ -470,7 +470,7 @@ static final class MyTAsin {
static {
init();
}
private static strictfp void init() {
private static void init() {
for (int i=0;i<ASIN_TABS_SIZE;i++) {
// x: in [0,ASIN_MAX_VALUE_FOR_TABS].
double x = i * ASIN_DELTA;
Expand Down Expand Up @@ -505,7 +505,7 @@ static final class MyTAsinPow {
static {
init();
}
private static strictfp void init() {
private static void init() {
if (FM_USE_POWTABS_FOR_ASIN || SFM_USE_POWTABS_FOR_ASIN) {
for (int i=0;i<ASIN_POWTABS_SIZE;i++) {
// x: in [0,ASIN_MAX_VALUE_FOR_POWTABS].
Expand Down Expand Up @@ -566,7 +566,7 @@ static final class MyTAtan {
static {
init();
}
private static strictfp void init() {
private static void init() {
for (int i=0;i<ATAN_TABS_SIZE;i++) {
// x: in [0,ATAN_MAX_VALUE_FOR_TABS].
double x = i * ATAN_DELTA;
Expand Down Expand Up @@ -641,7 +641,7 @@ static final class MyTExp {
static {
init();
}
private static strictfp void init() {
private static void init() {
for (int i=(int)EXP_UNDERFLOW_LIMIT;i<=(int)EXP_OVERFLOW_LIMIT;i++) {
expHiTab[i-(int)EXP_UNDERFLOW_LIMIT] = StrictMath.exp(i);
}
Expand Down Expand Up @@ -670,7 +670,7 @@ static final class MyTLog {
static {
init();
}
private static strictfp void init() {
private static void init() {
for (int i=0;i<LOG_TAB_SIZE;i++) {
// Exact to use inverse of tab size, since it is a power of two.
double x = 1+i*(1.0/LOG_TAB_SIZE);
Expand All @@ -692,7 +692,7 @@ static final class MyTTwoPow {
static {
init();
}
private static strictfp void init() {
private static void init() {
if (USE_TWO_POW_TAB) {
for (int i=MIN_DOUBLE_EXPONENT;i<=MAX_DOUBLE_EXPONENT;i++) {
twoPowTab[i-MIN_DOUBLE_EXPONENT] = NumbersUtils.twoPow(i);
Expand All @@ -716,7 +716,7 @@ static final class MyTSqrt {
static {
init();
}
private static strictfp void init() {
private static void init() {
for (int i=MIN_DOUBLE_EXPONENT;i<=MAX_DOUBLE_EXPONENT;i++) {
double twoPowExpDiv2 = StrictMath.pow(2.0,i*0.5);
sqrtXSqrtHiTab[i-MIN_DOUBLE_EXPONENT] = twoPowExpDiv2 * 0.5; // Half sqrt, to avoid overflows.
Expand Down Expand Up @@ -756,7 +756,7 @@ static final class MyTCbrt {
static {
init();
}
private static strictfp void init() {
private static void init() {
for (int i=MIN_DOUBLE_EXPONENT;i<=MAX_DOUBLE_EXPONENT;i++) {
double twoPowExpDiv3 = StrictMath.pow(2.0,i*(1.0/3));
cbrtXCbrtHiTab[i-MIN_DOUBLE_EXPONENT] = twoPowExpDiv3 * 0.5; // Half cbrt, to avoid overflows.
Expand Down Expand Up @@ -1605,7 +1605,7 @@ static int decodeQuadrant(long bits) {
* @param angle Angle, in radians.
* @return Remainder of (angle % (2*PI)), in [-PI,PI].
*/
static strictfp double jdkRemainderTwoPi(double angle) {
static double jdkRemainderTwoPi(double angle) {
final double sin = StrictMath.sin(angle);
final double cos = StrictMath.cos(angle);
return StrictMath.atan2(sin, cos);
Expand All @@ -1615,7 +1615,7 @@ static strictfp double jdkRemainderTwoPi(double angle) {
* @param angle Angle, in radians.
* @return Remainder of (angle % PI), in [-PI/2,PI/2].
*/
static strictfp double jdkRemainderPi(double angle) {
static double jdkRemainderPi(double angle) {
final double sin = StrictMath.sin(angle);
final double cos = StrictMath.cos(angle);
/*
Expand All @@ -1630,7 +1630,7 @@ static strictfp double jdkRemainderPi(double angle) {
* @return Bits of double corresponding to remainder of (angle % (PI/2)),
* in [-PI/4,PI/4], with quadrant encoded in exponent bits.
*/
static strictfp long jdkRemainderPiO2(double angle, boolean negateRem) {
static long jdkRemainderPiO2(double angle, boolean negateRem) {
final double sin = StrictMath.sin(angle);
final double cos = StrictMath.cos(angle);

Expand Down Expand Up @@ -1678,7 +1678,7 @@ static strictfp long jdkRemainderPiO2(double angle, boolean negateRem) {
* @param angle Angle, in radians. Must not be NaN nor +-Infinity.
* @return Remainder of (angle % (2*PI)), in [-PI,PI].
*/
static strictfp double heavyRemainderTwoPi(double angle) {
static double heavyRemainderTwoPi(double angle) {
final long remAndQuad = heavyRemainderPiO2(angle, false);
final double rem = decodeRemainder(remAndQuad);
final int q = decodeQuadrant(remAndQuad);
Expand All @@ -1701,7 +1701,7 @@ static strictfp double heavyRemainderTwoPi(double angle) {
* @param angle Angle, in radians. Must not be NaN nor +-Infinity.
* @return Remainder of (angle % PI), in [-PI/2,PI/2].
*/
static strictfp double heavyRemainderPi(double angle) {
static double heavyRemainderPi(double angle) {
final long remAndQuad = heavyRemainderPiO2(angle, false);
final double rem = decodeRemainder(remAndQuad);
final int q = decodeQuadrant(remAndQuad);
Expand Down Expand Up @@ -1729,7 +1729,7 @@ static strictfp double heavyRemainderPi(double angle) {
* @return Bits of double corresponding to remainder of (angle % (PI/2)),
* in [-PI/4,PI/4], with quadrant encoded in exponent bits.
*/
static strictfp long heavyRemainderPiO2(double angle, boolean negateRem) {
static long heavyRemainderPiO2(double angle, boolean negateRem) {

/*
* fdlibm treatments unrolled, to avoid garbage and be OOME-free,
Expand Down
24 changes: 12 additions & 12 deletions src/main/java/net/jafama/NumbersUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -115,15 +115,15 @@ public final class NumbersUtils {
*/
public static boolean equal(float a, float b) {
// Only does one test if a == b.
return (a == b) ? true : ((a != a) && (b != b));
return a == b || ((a != a) && (b != b));
}

/**
* @return True if the specified values are equal or both NaN, false otherwise.
*/
public static boolean equal(double a, double b) {
// Only does one test if a == b.
return (a == b) ? true : ((a != a) && (b != b));
return a == b || ((a != a) && (b != b));
}

/**
Expand Down Expand Up @@ -1530,7 +1530,7 @@ public static float pow2(float a) {
* @param a A value.
* @return a*a.
*/
public static strictfp float pow2_strict(float a) {
public static float pow2_strict(float a) {
return a*a;
}

Expand All @@ -1548,7 +1548,7 @@ public static double pow2(double a) {
* @param a A value.
* @return a*a.
*/
public static strictfp double pow2_strict(double a) {
public static double pow2_strict(double a) {
return a*a;
}

Expand Down Expand Up @@ -1582,7 +1582,7 @@ public static float pow3(float a) {
* @param a A value.
* @return a*a*a.
*/
public static strictfp float pow3_strict(float a) {
public static float pow3_strict(float a) {
return a*a*a;
}

Expand All @@ -1600,7 +1600,7 @@ public static double pow3(double a) {
* @param a A value.
* @return a*a*a.
*/
public static strictfp double pow3_strict(double a) {
public static double pow3_strict(double a) {
return a*a*a;
}

Expand Down Expand Up @@ -1628,7 +1628,7 @@ public static double plus2PI(double angRad) {
* @param angRad An angle, in radians.
* @return angRad + 2*PI, accurately computed.
*/
public static strictfp double plus2PI_strict(double angRad) {
public static double plus2PI_strict(double angRad) {
if (angRad > -Math.PI) {
// LO then HI, for better accuracy (if starting near 0).
return (angRad + TWOPI_LO) + TWOPI_HI;
Expand Down Expand Up @@ -1658,7 +1658,7 @@ public static double minus2PI(double angRad) {
* @param angRad An angle, in radians.
* @return angRad - 2*PI, accurately computed.
*/
public static strictfp double minus2PI_strict(double angRad) {
public static double minus2PI_strict(double angRad) {
if (angRad < Math.PI) {
// LO then HI, for better accuracy (if starting near 0).
return (angRad - TWOPI_LO) - TWOPI_HI;
Expand Down Expand Up @@ -1688,7 +1688,7 @@ public static double plusPI(double angRad) {
* @param angRad An angle, in radians.
* @return angRad + PI, accurately computed.
*/
public static strictfp double plusPI_strict(double angRad) {
public static double plusPI_strict(double angRad) {
if (angRad > -Math.PI/2) {
// LO then HI, for better accuracy (if starting near 0).
return (angRad + PI_LO) + PI_HI;
Expand Down Expand Up @@ -1718,7 +1718,7 @@ public static double minusPI(double angRad) {
* @param angRad An angle, in radians.
* @return angRad - PI, accurately computed.
*/
public static strictfp double minusPI_strict(double angRad) {
public static double minusPI_strict(double angRad) {
if (angRad < Math.PI/2) {
// LO then HI, for better accuracy (if starting near 0).
return (angRad - PI_LO) - PI_HI;
Expand Down Expand Up @@ -1748,7 +1748,7 @@ public static double plusPIO2(double angRad) {
* @param angRad An angle, in radians.
* @return angRad + PI/2, accurately computed.
*/
public static strictfp double plusPIO2_strict(double angRad) {
public static double plusPIO2_strict(double angRad) {
if (angRad > -Math.PI/4) {
// LO then HI, for better accuracy (if starting near 0).
return (angRad + PIO2_LO) + PIO2_HI;
Expand Down Expand Up @@ -1778,7 +1778,7 @@ public static double minusPIO2(double angRad) {
* @param angRad An angle, in radians.
* @return angRad - PI/2, accurately computed.
*/
public static strictfp double minusPIO2_strict(double angRad) {
public static double minusPIO2_strict(double angRad) {
if (angRad < Math.PI/4) {
// LO then HI, for better accuracy (if starting near 0).
return (angRad - PIO2_LO) - PIO2_HI;
Expand Down

0 comments on commit e78fa4f

Please sign in to comment.