Use static final int for IEEE exponent shift constant.

Closes #156.
This commit is contained in:
Mohammad Rezaei 2020-07-21 10:35:13 -04:00 committed by Gilles Sadowski
parent 3ed7faba1b
commit 9e24ff70a7
1 changed files with 4 additions and 2 deletions

View File

@ -87,6 +87,8 @@ class SimplexTableau implements Serializable {
private static final int MIN_IEEE_EXP = 0; private static final int MIN_IEEE_EXP = 0;
/** IEEE exponent is kept in an offset form, 1023 is zero **/ /** IEEE exponent is kept in an offset form, 1023 is zero **/
private static final int OFFSET_IEEE_EXP = 1023; 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. */ /** Linear objective function. */
private final LinearObjectiveFunction f; private final LinearObjectiveFunction f;
@ -421,7 +423,7 @@ class SimplexTableau implements Serializable {
*/ */
private static int exponent(double d) { private static int exponent(double d) {
long bits = Double.doubleToLongBits(d); long bits = Double.doubleToLongBits(d);
return (int) ((bits & EXPN) >>> 52); return (int) ((bits & EXPN) >>> IEEE_EXPONENT_SHIFT);
} }
/** /**
@ -436,7 +438,7 @@ class SimplexTableau implements Serializable {
return d; return d;
} }
long bits = Double.doubleToLongBits(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));
} }
/** /**