PDA

View Full Version : Disable scientific notation



guiismiti
7th December 2014, 03:12
Hi,

Search for 1e+0 or scientific notation returned no results.

What I need is simple - disable scientific notation. As you can see, the value of 1000000 in the top right hud is being displayed in scientific notation as 1e+006.

808

That just doesn't look good.

These are the values I'm using in this case:


self.rank = 6;
level.rankpoints[7] = 1000000;
self.nextrankpoints = level.rankpoints[self.rank + 1];


and this is the code for the hud:


if(isdefined(self.hud_maxxp))
self.hud_maxxp destroy();

self.hud_maxxp = newClientHudElem(self);
self.hud_maxxp.x = -62;
self.hud_maxxp.y = 15;
self.hud_maxxp.alignx = "left";
self.hud_maxxp.aligny = "middle";
self.hud_maxxp.horzAlign = "right";
self.hud_maxxp.vertAlign = "top";
self.hud_maxxp.fontScale = 1;
self.hud_maxxp.label = (&"MP_SLASH");
self.hud_maxxp setValue(self.nextrankpoints);
self.hud_maxxp.sort = 9971;


Thanks in advance.


P.S. Coronel is not a typo, it's portuguese for Colonel.

serthy
7th December 2014, 08:15
the only thing that comes into my mind is: if this hud is static (no fade, move, scale) use a menu + client cvar

guiismiti
7th December 2014, 08:45
I'm thinking about converting this hud into a text hud, but it's a workaround... not the best option.

PatmanSan
7th December 2014, 09:31
If a simple int(x) doesn't do the trick, you can try to convert it using this function:



roundDecimal(f, decimals)
{
if(!isDefined(decimals)) decimals = 1;
whole = int(f);
switch(decimals)
{
case 5: fraction = (int(100000 * (f - whole) + 0.5)) / 100000; break; // 5 decimals
case 4: fraction = (int(10000 * (f - whole) + 0.5)) / 10000; break; // 4 decimals
case 3: fraction = (int(1000 * (f - whole) + 0.5)) / 1000; break; // 3 decimals
case 2: fraction = (int(100 * (f - whole) + 0.5)) / 100; break; // 2 decimals
default: fraction = (int(10 * (f - whole) + 0.5)) / 10; // 1 decimal
}
return(whole + fraction);
}