Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / September 2005

Tip: Looking for answers? Try searching our database.

Struts Validator floatRange has roundoff error

Thread view: 
m_p_v_13 - 30 Sep 2005 16:40 GMT
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
Roedy Green - 30 Sep 2005 21:38 GMT
>For the validation.xml configuration snippet below, user input of
>90.00001 fails validation, as expected, but 90.000001 does not.

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
Signature

Canadian Mind Products, Roedy Green.
http://mindprod.com Again taking new Java programming contracts.

Andrew Thompson - 30 Sep 2005 22:24 GMT
>>For the validation.xml configuration snippet below, user input of
>>90.00001 fails validation, as expected, but 90.000001 does not.
>
> 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?


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.