ordinal.c

ds2.10/lib/secure/sefun/ordinal.c · 423 B

From the archive ds2.10.zip

Download the archive   « Back to the archive contents

//      /adm/simul_efun/ordinal.c
//      from the Dead Souls Mudlib
//      returns a string with the ordinal suffix for an int 
//      created by Descartes of Borg 03 july 1993

string ordinal(int x) {
    if( x<14 && x>10 ) x = 4;
    else x = x%10;
    switch(x) {
        case 1: return "st"; break;
        case 2: return "nd"; break;
        case 3: return "rd"; break;
        default: return "th"; break;
    }
}

Site Stats

Snippets: 1791
Codebases: 571