Write a function/method/subroutine/... that when given an integer greater than or equal to zero returns a string of the number followed by an apostrophe then the ordinal suffix.



Example

Returns would include 1'st 2'nd 3'rd 11'th 111'th 1001'st 1012'th



Task

Use your routine to show here the output for at least the following (inclusive) ranges of integer inputs:
0..25, 250..265, 1000..1025


Note: apostrophes are now optional to allow correct apostrophe-less English.




For x = 0 to 25                        ' Test range 0..25
  Push x : GoSub _PrintOrdinal
Next x  : Print
 
For x = 250 to 265                     ' Test range 250..265
  Push x : GoSub _PrintOrdinal
Next x : Print
 
For x = 1000 to 1025                   ' Test range 1000..1025
  Push x : GoSub _PrintOrdinal
Next x : Print
 
End                                    ' End test program
                                       ' ( n --)
_PrintOrdinal                          ' Ordinal subroutine
  If Tos() > -1 Then                   ' If within range then
    Print Using "____#";Tos();"'";     ' Print the number
                                       ' Take care of 11, 12 and 13
    If (Tos()%100 > 10) * (Tos()%100 < 14) Then
       Gosub (Pop() * 0) + 100         ' Clear stack and print "th"
       Return                          ' We're done here
    EndIf
 
    Push Pop() % 10                    ' Calculate n mod 10
    GoSub 100 + 10 * ((Tos()>0) + (Tos()>1) + (Tos()>2) - (3 * (Pop()>3)))
  Else                                 ' And decide which ordinal to use
    Print Pop();" is less than zero"   ' Otherwise, it is an error
  EndIf
 
Return
                                       ' Select and print proper ordinal
100 Print "th"; : Return
110 Print "st"; : Return
120 Print "nd"; : Return
130 Print "rd"; : Return