I'm using what_percent to display health also in a percent.
But it displays 6 decimal places, which is far too many. Without changing the what_percent function (so I can use it for math later on) how do I format it to show only 2 decimal places? As you can tell I can't seem to format it like normal.
pager_printf_color(ch, "&OHealth&c: &G%s", num_punct(ch->hit) );
pager_printf_color(ch, " &wof &g%s &z(&W%-4f&w%%&z)\n\r", num_punct(ch->max_hit), what_percent(ch->hit, ch->max_hit) );
float what_percent( float x, float y)
{
float z=0;
float n=0;
z = (y/100);
/* z now equals 1% of y */
/* How many times will Z go into X ? */
n = x/z;
return n;
}
But it displays 6 decimal places, which is far too many. Without changing the what_percent function (so I can use it for math later on) how do I format it to show only 2 decimal places? As you can tell I can't seem to format it like normal.