Thanks Oscar! I haven't tried yet, but it seems that you're correct. While I don't want to convert whole thing to BigDecimal, I think converting to an integer will workout wonderfully since option strike prices currently do not go beyond 3 decimal places. Perhaps Stripes needs to make a special case for Double/Float comparisons for this particular reason although I wouldn't consider this situation a bug at all.

Daniil


PS: Funny how you picked that up, hope you're not one of our clients or that would be embarrassing



On 10/13/2010 1:12 AM, Oscar Westra van Holthe - Kind wrote:
On 12-10-2010 at 17:27, Daniil Sosonkin wrote:
  <body bgcolor="#ffffff" text="#000000">
    <font size="-1"><font face="Tahoma">To all, not even sure this is a
        bug or am I doing something wrong, but I just can get the value
        selected properly. The code fragment is as follows:<br>
        <br>
        &lt;s:select class="fields" name="strike" value="${strike}"&gt;<br>
        &lt;s:options-collection collection="${strikes}"/&gt;<br>
        &lt;/s:select&gt;<br>
        <br>
        The form submits to an action bean that has getters and setters
        for the "private double strike".<br>
Not sure if it helps, but doubles and floats are infamous for this kind of
thing. The select tag does an equality comparison, and floats and especially
doubles are a little imprecise so that fails. This is also why an equality
test on a float/double is taught as "Math.abd(d1-d2) < 0.00000000001" or
similar instead of "d1 == d2" / "d1.equals(d2)".

In your situation, I'd convert the monetary value of the option's strike
price to a fixed point number (using a BigDecimal with a scale of 2, 3 or
maybe 5) or even an integer number (the BigDecimal multiplied by 100, 1000 or
100000).


Oscar

------------------------------------------------------------------------------
Beautiful is writing same markup. Internet Explorer 9 supports
standards for HTML5, CSS3, SVG 1.1,  ECMAScript5, and DOM L2 & L3.
Spend less time writing and  rewriting code and more time creating great
experiences on the web. Be a part of the beta today.
http://p.sf.net/sfu/beautyoftheweb
_______________________________________________
Stripes-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/stripes-users

Reply via email to