Re: Getting the th of a Number

new topic     » goto parent     » topic index » view thread      » older message » newer message
euphoric said...

Anybody know if we have a library for getting the 'th' of a number. grin I know that's not the term... but I don't know what it is.

I want to input 15 and get back 15th, or input 3 and get back 3rd.

Thanks! smile

function th(integer n) 
  if n = 1 then 
    return "1st" 
  elsif n = 2 then 
   return "2d" 
  elsif n = 3 then 
   return "3rd" 
  else 
   return sprintf("%dth",n) 
  end if 
end function 


jacques

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu