MCPcopy Create free account
hub / github.com/NetHack/NetHack / ordin

Function ordin

src/hacklib.c:624–631  ·  view source on GitHub ↗

return the ordinal suffix of a number */

Source from the content-addressed store, hash-verified

622
623/* return the ordinal suffix of a number */
624const char *
625ordin(int n) /* note: should be non-negative */
626{
627 int dd = n % 10;
628
629 return (dd == 0 || dd > 3 || (n % 100) / 10 == 1) ? "th"
630 : (dd == 1) ? "st" : (dd == 2) ? "nd" : "rd";
631}
632
633DISABLE_WARNING_FORMAT_NONLITERAL /* one compiler complains about
634 result of ?: for format string */

Callers 7

mshot_xnameFunction · 0.85
toptenFunction · 0.85
endmultishotFunction · 0.85
logdeadmonFunction · 0.85
maybe_finish_sokobanFunction · 0.85
attributes_enlightenmentFunction · 0.85
mstatuslineFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected