Fractional penalty values are rounded to the nearest whole number because of the limited number of bits available (four) for decimal encoding, and the specified factor (1).
penaltyEnc = new DecimalEncodedValueImpl(getKey(name, "penalty"), 4, PenaltyCode.getFactor(1), penaltyTwoDirections);
Therefore, the only possible values for penalties are the whole numbers 0-15. For example, 9.5 will be rounded to 10.0.
If we want to respect half-point penalty values, then the above code should be changed to
penaltyEnc = new DecimalEncodedValueImpl(getKey(name, "penalty"), 5, 0.5, penaltyTwoDirections);
increasing the number of bits from 4 to 5, and the factor from 1.0 to 0.5.
However, since I don't know what the performance implications are wrt increasing the number of bits, this change will maintain the same router behavior while making our code more readable.
Fractional penalty values are rounded to the nearest whole number because of the limited number of bits available (four) for decimal encoding, and the specified factor (1).
Therefore, the only possible values for penalties are the whole numbers
0-15
. For example,9.5
will be rounded to10.0
.If we want to respect half-point penalty values, then the above code should be changed to
increasing the number of bits from 4 to 5, and the factor from 1.0 to 0.5.
However, since I don't know what the performance implications are wrt increasing the number of bits, this change will maintain the same router behavior while making our code more readable.