code ferret Posted April 14, 2011 Report Share Posted April 14, 2011 I'm using the oglib_variantconfig library successfully, but I'd like to format the floats. I've experimented with the 'float number format (optional)' input, but it always fails. I've looked at the documentation but haven't seen any examples or explanations. Can anyone tell me how to use this feature? My input is a cluster with booleans, integers, and floats; I wish to format the floats. here's a pseudo-code example: cluster{ boolean one; boolean two; uint8 a; uint32 b; float c; float d; uint8 e; } I want to know how to tell "write section cluster" to format the two floats to 3 places. I've tried "%.3f" ".3", "3", ".3f", "%.3", etc. All cause errors. For reference, here's the documentation page: http://wiki.openg.or...Section_Cluster. I also found this page: http://opengtoolkit..../variantconfig/ which apears to be outdated. Quote Link to comment
Jim Kring Posted April 14, 2011 Report Share Posted April 14, 2011 Unfortunately, the float format string is global for all floats. You can't choose a different value for each one, individually. You might get good mileage using auto-formatting like this: %#_16g -- it will use 16 significant digits, hide trailing zeros, etc. Quote Link to comment
code ferret Posted April 15, 2011 Author Report Share Posted April 15, 2011 Unfortunately, the float format string is global for all floats. You can't choose a different value for each one, individually. You might get good mileage using auto-formatting like this: %#_16g -- it will use 16 significant digits, hide trailing zeros, etc. That did the trick - thanks! Quote Link to comment
Jim Kring Posted April 15, 2011 Report Share Posted April 15, 2011 That did the trick - thanks! Great! I'm glad that will work for you Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.