Struts Validator floatRange has roundoff error

M

m_p_v_13

The Struts Validator floatRange seems to have roundoff error.

For the validation.xml configuration snippet below, user input of
90.00001 fails validation, as expected, but 90.000001 does not.


<field property="baseLocalities.latitude" depends="float,floatRange">
<var>
<var-name>min</var-name>
<var-value>-90</var-value>
</var>
<var>
<var-name>max</var-name>
<var-value>90</var-value>
</var>
</field>


Is this a known problem?
What is the best way to work around it?

Thanks,
Michael
 
A

Andrew Thompson

Roedy said:
I did not analyse your particular problem, but nearly always such
anomalies are God's fault for making 0.1 a repeating fraction when
expressed in binary. See http://mindprod.com/floatingpoint.html

Did God command us to use base 10? In fact, what with the
entire Adam/Eve, 2x2 on the ark deal, it would seem '2'
is more likely the 'divine' number (for the Judeo-Christians).
If we didn't use base 10, why would we think twice about
the representation of such an obscure fraction as 1/10?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,586
Members
45,088
Latest member
JeremyMedl

Latest Threads

Top