N'th: Difference between revisions

83 bytes added ,  3 years ago
→‎{{header|UNIX Shell}}: Support negative numbers
No edit summary
(→‎{{header|UNIX Shell}}: Support negative numbers)
Line 3,307:
local ordinals=(th st nd rd)
local -i n=$1 i
if (( n < 0 )); then
printf '%s%s\n' - "$(nth $(( -n )) )"
return 0
fi
case $(( n % 100 )) in
11|12|13) i=0;;
1,481

edits