Sign in to follow this  
Followers 0
Sheep_Wizard

Change the number of decimals shown in a float?

4 posts in this topic

When you display a float number in menus it shows the  number with 6 decimal places (1.000000)

 

Is there anyway to limit the number of decimal places shown?

0

Share this post


Link to post
Share on other sites

I'll wait to see if anyone has a proper answer

If not I know a way using arrays and loops

0

Share this post


Link to post
Share on other sites

When you display a float number in menus it shows the  number with 6 decimal places (1.000000)

 

Is there anyway to limit the number of decimal places shown?

have ya tried thingy like printf in C? i.e. %.1f would display a float number with 1 decimal and %.2f with 2 and so on.

 

this may require custom localization strings to work or it may not work at all. at least you can see %s used in default localization strings like "player %s killed player %s" and functions like printLn() have their declarations as printLn(char* fmt, ...) in Q3 source (same as printf in C).

0

Share this post


Link to post
Share on other sites

If you still have no solution I've made a quick function to do it for you (gsc).

 

It just goes;

 

toDecimalPlace(0.2397420934, 4);

 

>>>0.2397

 

Unfortunately I haven't done the rounding aspect of it yet, but feel free leave a reply if you would like it.

0

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  
Followers 0