Re: Ordinal Numbers (1st, 2nd, etc.)
Re: Ordinal Numbers (1st, 2nd, etc.)
- Subject: Re: Ordinal Numbers (1st, 2nd, etc.)
- From: Nigel Garvey <email@hidden>
- Date: Fri, 17 Aug 2001 10:47:27 +0100
Jason Bourque wrote on Thu, 16 Aug 2001 22:05:20 -0400:
>
Ok one last try
>
>
>
on addNumericSuffix(thisNum)
>
>
if thisNum is 0 then return 0
>
>
set tempNum to "0" & thisNum
>
>
set numSuffix to "th"
>
>
if (character -2 of tempNum) is not "1" and (character -1 of tempNum) is
>
in {"1", "2", "3"} then
>
set numSuffix to item (character -1 of tempNum) of {"st", "nd",
>
"rd"}
>
end if
>
>
(thisNum & numSuffix) as text
>
end addNumericSuffix
That's very nice! :-) Just to speed it up a bit:
on addNumericSuffix(thisNum)
set {tens, units} to {thisNum mod 100 div 10, thisNum mod 10}
if units is in {1, 2, 3} and tens is not 1 then
item units of {"st", "nd", "rd"}
else
"th"
end if
return "" & thisNum & result
end addNumericSuffix
Is there a proper English way to ordinalise negatives and fractional
numbers? Minus oneth or minus first? 3.2th or 3.2nd?
NG