The converted string formatted according to the specified case, format, and Chinese script
For circular numeral types (all types present in numeralLength: latin_letter, greek_letter,
month_name, astrological_sign, etc.), automatically handles out-of-range numbers by wrapping them
using circular arithmetic. The circular handling is included in convertTo()
,
some specific toAbc()
functions include it too but many don't
convertTo(4, { type: 'roman', case: 'upper' }) // returns 'IV'
convertTo(4, { type: 'roman', case: 'lower' }) // returns 'iv'
convertTo(21, { type: 'english_words', case: 'title' }) // returns 'Twenty-One'
convertTo(21, { type: 'english_words', case: 'upper' }) // returns 'TWENTY-ONE'
convertTo(1, { type: 'latin_letter', case: 'lower' }) // returns 'a'
convertTo(27, { type: 'latin_letter', case: 'lower' }) // returns 'a' (wraps around)
convertTo(255, { type: 'hexadecimal', case: 'upper' }) // returns 'FF'
convertTo(1, { type: 'month_name', case: 'sentence', format: 'long' }) // returns 'January'
convertTo(1, { type: 'month_name', case: 'upper', format: 'short' }) // returns 'JAN'
convertTo(13, { type: 'month_name', case: 'upper', format: 'short' }) // returns 'JAN' (wraps to January)
convertTo(123, { type: 'chinese_words' }) // returns '一百二十三' (Simplified)
convertTo(123, { type: 'chinese_words', zhst: 1 }) // returns '一百二十三' (Traditional, same in this case)
convertTo(10000000000000, { type: 'chinese_words', zhst: 1 }) // returns '萬億' (Traditional)
convertTo(1, { type: 'astrological_sign', case: 'lower' }) // returns 'aries'
convertTo(13, { type: 'astrological_sign', case: 'lower' }) // returns 'aries' (wraps around)
convertTo(7, { type: 'day_of_week', case: 'lower' }) // returns 'sunday' (wraps around)
Generalized function to convert a number to a string based on the specified type. Supports precise control over output formatting through case and format properties. Case options: 'lower', 'upper', 'sentence' (first letter capitalized), 'title' (each word capitalized). Format options: 'short' or 'long' for dates/months. For Chinese types, supports Traditional/Simplified script conversion via zhst property: