26.11.2011, 15:55
What does it do different if you put "%f" rather than "%.2f" ??
Thanks for any help,
- Josh
Thanks for any help,
- Josh
// ..
printf( "%.2f", 3.141592 );
//Would output 3.14, because precision is 2 places.
// ..
printf( "%f", 3.141592 );
//Would output 3.141592, because there is no precision set.
// ..
printf( "%.4f", 3.141592 );
//Would output 3.1415, because precision is 4 places.
public OnPlayerSpawn(playerid)
{
new
Float: gHP,
string[32]
;
GetPlayerHealth(playerid, gHP);
format(string, sizeof(string), "HP: %f %.2f", gHP, gHP);
SendClientMessage(playerid, ~1, string);
return 1;
}
%.2f specifies the precision of the float to print out to 2. This would print out a float to 2 decimal places:
pawn Код:
https://sampwiki.blast.hk/wiki/Floats and more specifically; https://sampwiki.blast.hk/wiki/Floats#Float_-.3E_String |
So basically, it wouldnt matter whether you put .2f, it just makes it look neater?
|