Raised This Month: $32 Target: $400
 8% 

[ANY] Singular and Plural


Post New Thread Reply   
 
Thread Tools Display Modes
Chdata
Veteran Member
Join Date: Aug 2012
Location: Computer Chair, Illinois
Old 02-25-2017 , 13:36   Re: [ANY] Singular and Plural
Reply With Quote #11

Quote:
Originally Posted by KyleS View Post
Ah yes, the 0th

Instead of going into macro, modulo, and ternary hell, try something untested like this:
PHP Code:
static stock NatStuf(number)
{
    static const 
String:InternalPrefix[][] = {"""st""nd""rd""th"};
    new 
mod = (number 10);
    if (
mod 3)
        
mod = (sizeof(InternalPrefix) - 1);
    
    return 
_:InternalPrefix[mod];

It's a macro cause the situations that a string can be returned are unclear/too weird for me to memorize

¯\_(ツ)_/¯
__________________
Chdata is offline
B3none
AlliedModders Donor
Join Date: Oct 2016
Location: United Kingdom
Old 04-24-2017 , 08:09   Re: [ANY] Singular and Plural
Reply With Quote #12

Nice share, tyvm
__________________
B3none is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 16:28.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode