This may be a bit ot, but I was looking at the JSpinnerModel and noticed that it does not implement any sort of user input validation
I need a way, given a users input, to determine if the given number falls within a given range. I have been able to validate about 90% of the time but I still have false-failures, and therefore potentially false-positives.
Example: Given a range of min=15.0, max100.0, step=0.01 how can I validate if any numeric value entered by a user matches that range.
I think i've got the min and max test down :)
I'll give an example of what I have tried:
float t1 = (value-cMinValue)/cStepValue;
// less than min
boolean minTest = value >= cMinValue;
// more than max
boolean maxTest = value <= cMaxValue;
// t1 should be a non-negative value
boolean negTest = (t1 == Math.abs(t1));
// t1 should be a non-decimal value
boolean wholeTest = (t1 == (int)t1);
boolean ok = minTest && maxTest && wholeTest && negTest;
I have tried several searches, but maybe I just don't know the proper terminology for what I am trying to do -- any input, pointers or algorithm details would be a great help
tia
kw