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