From WikiChip
$ord Identifier - mIRC
< mirc‎ | identifiers
Revision as of 03:26, 18 January 2019 by Maroonbells (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

$ord appends "st", "nd", "rd", or "th" as appropriate, to the number N.

Synopsis[edit]

$ord(N)

Parameters[edit]

  • N - The number

Properties[edit]

None

Example[edit]

//echo -a $ord(3)

Rules:

  1. If number ends with 11 12 or 13, suffix is th
  2. If number ends with 1 the suffix is st
  3. If number ends with 2 the suffix is nd
  4. If number ends with 3 the suffix is rd
  5. All other numbers end with th, including zero.

This code shows that following these 5 rules produces the same output as letting mIRC calculate the Ordinal. It repeatedly hashes a string consisting of the previous hash combined with the $ord of the next number, and both methods produce the identical hash:

//var %a , %a2 , %i 0 | while (%i isnum 0-999) { if ($istok(11 12 13,$right(%i,2),32)) var %ord th | elseif ($findtok(1 2 3,$right(%i,1),1,32)) var %ord $gettok(st nd rd,$v1,32) | else var %ord th | var %a $sha1(%a %i $+ %ord) , %a2 $sha1(%a2 $ord(%i)) | inc %i } | echo -a %a , %a2

For fractions, the $ord uses the last 1 or 2 digits of the fraction.

//echo -a $ord(2.1) and $ord($pi)

Compatibility[edit]

Added: mIRC v5.61
Added on: 23 Sep 1999
Note: Unless otherwise stated, this was the date of original functionality.
Further enhancements may have been made in later versions.

See Also[edit]