convnum
    Preparing search index...

    Function toBasicRange

    • Converts any number (including negative, 0, or numbers greater than the range) to the corresponding number in the basic range [1, length] for a given numeral type. Uses circular/modular arithmetic to wrap around the valid range.

      Parameters

      • n: number

        The input number (can be any integer)

      • numType: NumType

        The numeral type to get the length for

      Returns number

      The equivalent number in the valid range [1, length]

      Error if the numeral type doesn't have a defined length

      toBasicRange(13, 'astrological_sign') // returns 1 (13 % 12 = 1)
      toBasicRange(0, 'latin_letter') // returns 26 (0 wraps to end)
      toBasicRange(-1, 'latin_letter') // returns 25 (-1 wraps to second-to-last)
      toBasicRange(27, 'latin_letter') // returns 1 (27 % 26 = 1)
      toBasicRange(25, 'chinese_earthly_branch') // returns 1 (25 % 12 = 1)