<Swing Dev> [15] RFR JDK-8220811: SpinnerNumberModel floating point rounding issue

Sergey Bylokhov Sergey.Bylokhov at oracle.com
Mon Feb 17 10:35:40 UTC 2020


On 2/17/20 2:25 am, Alexey Ivanov wrote:
>> As far as I understand your approach, is to select the minimum if the resulted float value after the calculation is a little bit smaller than the minimum.
>>
>> So if the minimum is -0.15 and resulted value is (-0.10d - 0.05d) = (-0.15000000000000002), what value should be shown by the spinner?
>> the same logic for int:
>>       the minimum is -15 and resulted value is (-11 - 5) = -16, what value should be shown by the spinner?
>>
> The set minimum value: -0.15d and -15 correspondingly.

That will contradicts the spec of SpinnerNumberModel.getNextValue/getPreviousValue which states that "@returns value - stepSize, or
null if the sum is less than minimum."


-- 
Best regards, Sergey.


More information about the swing-dev mailing list