Converting Numbers to Ordinal Numbers: A Simple Guide

Understanding ordinal numbers is essential in language and mathematics. They denote a position in a sequence or order, such as first, second, third, and so forth. While cardinal numbers represent quantity, ordinal numbers specify the position or order of elements in a series. Converting cardinal numbers to ordinal numbers is a straightforward process, yet it’s an aspect of language that can sometimes be overlooked. In this article, we’ll explore how to convert numbers to their ordinal equivalents.

What Are Ordinal Numbers?

Ordinal numbers are adjectives that indicate the position or order of elements in a sequence. They are used to rank items or indicate a specific place in a series. For example:

  • First
  • Second
  • Third
  • Fourth
  • Fifth

In writing, ordinal numbers are often abbreviated with superscript letters (1st, 2nd, 3rd, etc.), but in this article, we’ll focus on the full word format.

Converting Cardinal Numbers to Ordinal Numbers

Converting cardinal numbers (e.g., 1, 2, 3) to ordinal numbers (e.g., first, second, third) follows a simple set of rules:

  1. For most numbers: Add “th” to the cardinal number. For example:
  • 1 becomes first
  • 2 becomes second
  • 3 becomes third
  • 4 becomes fourth
  • 5 becomes fifth
  • And so on…
  1. Exceptions: There are a few exceptions to this rule:
  • 1 becomes first
  • 2 becomes second
  • 3 becomes third
  • 5 becomes fifth
  • 8 becomes eighth
  • 9 becomes ninth
  • 12 becomes twelfth
  • The multiples of 10 (except for 10 itself) end in “th,” such as 20th, 30th, 40th, and so on.
  1. Special Cases: Some numbers have irregular ordinal forms:
  • 11 becomes eleventh
  • 12 becomes twelfth
  • 13 becomes thirteenth
  • 20 becomes twentieth
  • 21 becomes twenty-first
  • 22 becomes twenty-second
  • And so forth…

Examples of Converting Cardinal Numbers to Ordinal Numbers

Let’s take a few cardinal numbers and convert them into their ordinal counterparts:

  1. 1 – first
  2. 4 – fourth
  3. 10 – tenth
  4. 13 – thirteenth
  5. 21 – twenty-first
  6. 100 – one hundredth
  7. 123 – one hundred and twenty-third

Here’s a JavaScript function that converts cardinal numbers to ordinal numbers:

function convertToOrdinal(number) {
    if (typeof number !== 'number' || isNaN(number)) {
        return 'Invalid input';
    }

    if (number === 0) {
        return 'Zeroth';
    }

    if (number % 100 >= 11 && number % 100 <= 13) {
        return number + 'th';
    }

    switch (number % 10) {
        case 1:
            return number + 'st';
        case 2:
            return number + 'nd';
        case 3:
            return number + 'rd';
        default:
            return number + 'th';
    }
}

// Test cases
console.log(convertToOrdinal(1));   // Output: 1st
console.log(convertToOrdinal(2));   // Output: 2nd
console.log(convertToOrdinal(3));   // Output: 3rd
console.log(convertToOrdinal(4));   // Output: 4th
console.log(convertToOrdinal(11));  // Output: 11th
console.log(convertToOrdinal(12));  // Output: 12th
console.log(convertToOrdinal(13));  // Output: 13th
console.log(convertToOrdinal(20));  // Output: 20th
console.log(convertToOrdinal(21));  // Output: 21st
console.log(convertToOrdinal(22));  // Output: 22nd
console.log(convertToOrdinal(100)); // Output: 100th
console.log(convertToOrdinal(123)); // Output: 123rd

This function convertToOrdinal() takes a number as input and returns its corresponding ordinal representation. It covers the exceptions and special cases as discussed earlier in the article.

Here’s a JavaScript function to convert cardinal numbers to string ordinal representation:

function convertToOrdinalString(number) {
    if (typeof number !== 'number' || isNaN(number)) {
        return 'Invalid input';
    }

    const ones = ['Zeroth', 'First', 'Second', 'Third', 'Fourth', 'Fifth', 'Sixth', 'Seventh', 'Eighth', 'Ninth'];
    const teens = ['Tenth', 'Eleventh', 'Twelfth', 'Thirteenth', 'Fourteenth', 'Fifteenth', 'Sixteenth', 'Seventeenth', 'Eighteenth', 'Nineteenth'];
    const tens = ['', 'Tenth', 'Twentieth', 'Thirtieth', 'Fortieth', 'Fiftieth', 'Sixtieth', 'Seventieth', 'Eightieth', 'Ninetieth'];
    const others = ['', 'First', 'Second', 'Third', 'Fourth', 'Fifth', 'Sixth', 'Seventh', 'Eighth', 'Ninth'];

    if (number === 0) {
        return ones[0];
    }

    if (number < 10) {
        return ones[number];
    }

    if (number < 20) {
        return teens[number - 10];
    }

    const digit = number % 10;
    const ten = Math.floor(number / 10);

    return tens[ten] + ' ' + others[digit];
}

// Test cases
console.log(convertToOrdinalString(1));   // Output: First
console.log(convertToOrdinalString(2));   // Output: Second
console.log(convertToOrdinalString(3));   // Output: Third
console.log(convertToOrdinalString(4));   // Output: Fourth
console.log(convertToOrdinalString(11));  // Output: Eleventh
console.log(convertToOrdinalString(12));  // Output: Twelfth
console.log(convertToOrdinalString(13));  // Output: Thirteenth
console.log(convertToOrdinalString(20));  // Output: Twentieth
console.log(convertToOrdinalString(21));  // Output: Twenty First
console.log(convertToOrdinalString(22));  // Output: Twenty Second
console.log(convertToOrdinalString(100)); // Output: One Hundredth
console.log(convertToOrdinalString(123)); // Output: One Hundred and Twenty Third

This function convertToOrdinalString() takes a number as input and returns its corresponding string ordinal representation. It covers numbers up to 999 (inclusive) and follows English ordinal naming conventions.

Leave a Reply