I am not able to find any issue with this approach.
Sometimes there are difference:
double b = 0.10000000000000011;
constructor [1]: 0.1000000000000001165734175856414367444813251495361328125
constructor [2]: 0.10000000000000012
<<But it is possible to create Float.valueOf(float) and pass it to this
constructor, isn't it? this will work for any primitives.
<<[3] public SpinnerNumberModel(Number value,
Comparable<?> minimum,
Comparable<?> maximum,
Number stepSize)
Yes, it is true. If we create "Float" objects from primitive float and pass to
the constructor, things work fine. But what if the user is passing the primitive float
values directly? As the double constructor is there, it is called instead of this
constructor which accepts objects. This creates issue.
I don’t see this in spec that users should not use primitive float directly and should
first create "Float" object and then create SpinnerNumberModel. So they will
use primitive floats directly and run into these issues.
This is described in the top level specification of this class.
As I suggested earlier, either we should remove constructors with primitive
double or add constructor for primitive float.
The primitive variants are there because it was decided that "integers and
doubles" are quite common, so they have special constructors, this is also described
in the top-level spec of the class.
--
Best regards, Sergey.