Jump to content

variantConfig float number format


Recommended Posts

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.

Link to comment

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.

Link to comment

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!

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.