20.09.2010, 19:40
(
Последний раз редактировалось RyDeR`; 20.09.2010 в 20:26.
)
Info (returnOrdinal) (updated)
Returns the ordinal form of a number.
Code
Usage
will print:
etc..
NOTE: This is an update on this: http://forum.sa-mp.com/showpost.php?...&postcount=907
So if someone is using it, please switch to this one because it's working almost 2 times faster.
@DarK TeaM PT:
No, I didn't see you returned an integer.
Returns the ordinal form of a number.
Code
pawn Код:
stock returnOrdinal(number)
{
new
ordinal[4][3] = { "st", "nd", "rd", "th" }
;
number = number < 0 ? -number : number;
return (((10 < (number % 100) < 14)) ? ordinal[3] : (0 < (number % 10) < 4) ? ordinal[((number % 10) - 1)] : ordinal[3]);
}
pawn Код:
printf("%d'%s", 3, returnOrdinal(3));
pawn Код:
3'rd
NOTE: This is an update on this: http://forum.sa-mp.com/showpost.php?...&postcount=907
So if someone is using it, please switch to this one because it's working almost 2 times faster.
@DarK TeaM PT:
No, I didn't see you returned an integer.