Skip to content

Commit

Permalink
Use static final int for IEEE exponent shift constant.
Browse files Browse the repository at this point in the history
  • Loading branch information
mohrezaei committed Jul 21, 2020
1 parent 3ed7fab commit 05ae250
Showing 1 changed file with 4 additions and 2 deletions.
Expand Up @@ -87,6 +87,8 @@ class SimplexTableau implements Serializable {
private static final int MIN_IEEE_EXP = 0;
/** IEEE exponent is kept in an offset form, 1023 is zero **/
private static final int OFFSET_IEEE_EXP = 1023;
/** double exponent shift per IEEE standard **/
public static final int IEEE_EXPONENT_SHIFT = 52;

/** Linear objective function. */
private final LinearObjectiveFunction f;
Expand Down Expand Up @@ -421,7 +423,7 @@ private static void updateExponent(double[] dar, int exp) {
*/
private static int exponent(double d) {
long bits = Double.doubleToLongBits(d);
return (int) ((bits & EXPN) >>> 52);
return (int) ((bits & EXPN) >>> IEEE_EXPONENT_SHIFT);
}

/**
Expand All @@ -436,7 +438,7 @@ private static double updateExponent(double d, int exp) {
return d;
}
long bits = Double.doubleToLongBits(d);
return Double.longBitsToDouble((bits & FRAC) | ((((bits & EXPN) >>> 52) + exp) << 52));
return Double.longBitsToDouble((bits & FRAC) | ((((bits & EXPN) >>> IEEE_EXPONENT_SHIFT) + exp) << IEEE_EXPONENT_SHIFT));
}

/**
Expand Down

0 comments on commit 05ae250

Please sign in to comment.