Closed Ident closed 15 years ago
Original comment by Anonymous.
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 :)
Original comment by Paul Turner (Bitbucket: pturner, GitHub: pturner).
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.
Original comment by Anonymous.
Original reporter: FluXy
I had this problem again and fixed it this time by using the stringencoders library which also seems to be a lot faster. See the homepage : http://code.google.com/p/stringencoders/
I used the modp_dtoa function and modified it for std::string see the function float_to_string here : https://opensvn.csie.org/viewcvs.cgi/SMC/src/core/game_core.cpp?root=SMC&view=markup
hopefully this helped :)
Original comment by Paul Turner (Bitbucket: pturner, GitHub: pturner).
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.
Original report by Anonymous.
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.