Spinner setCurrentValue with float

Create issue
Issue #123 resolved
Former user created an issue

Automatic migration. Original reporter: "FluXy"

Setting a very small float value was giving this result "1e-05" and can be reproduced also in the Spinner itself setting f.e. "0.00001".

This is maybe coused because i compiled CEGUI with STLPort 5.0 ?

Reproducibility: always

Additional information: Compiled from source ( CEGUI 0.5 SVN 6.9.2006 ) with MSVC 8 and STLPort 5.0.

Comments (7)

  1. Former user Account Deleted

    Original reporter: FluXy

    I'm currently using a workaround : Editbox and the following function :

    string float_to_string( float number ) { std::ostringstream temp( std::ios_base::fixed ); temp << number;

    return temp.str(); }

    Hope this helps a bit :)

  2. Paul Turner

    I have confirmed that this is an issue with the system in general and is not related to your use of STLport.

    I am now looking for a satisfactory resolution to the issue (and some other related oddities that appear).

  3. Paul Turner

    This issue is caused by our use of a float and the std library to output the value to a string. By default, this will represent the value using either fixed or scientific notation depending upon which would result in the shorter output.

    I ran some tests always using fixed notation for output (as in your workaround), but found that the results varied wildly depending upon the value of the spinner and the precision set for the output. Seeing such things as typing '1.3' into the box, but having it then appear as '1.299987' or some such - obviously not a satisfactory result!

    It's been decided that, in order to get consistent performance out of the spinner for float values, a fairly substantial change to the widget is required. For this reason, and until such times as we can address this issue properly, I have added a note to the docs for Spinner warning of it's fairly unstable nature when using FloatingPoint mode.

  4. Paul Turner

    Thanks for the heads-up. I will take a look soon; it would be good to finally close this ticket! :)

  5. Paul Turner

    I have played around with the stringencoders a little and will incorporate this as part of a solution to this issue; the other part of the solution is changing the spinner to use the double precision type as opposed to float (I encountered other issues when using float due to lack of precision).

    The fix will be made in svn trunk and so will first appear in 0.7.0 (I would have liked to have done it for 0.6.1, but the changes break the binary interface in various ways (float to double change in public interface, and addition of static data)).

    I'll update again, and resolve the ticket, one the changes are in.

  6. Log in to comment