BigInt & Large Numbers β
to-words accepts bigint and precision-preserving string input, so values beyond Number.MAX_SAFE_INTEGER are never rounded or truncated. Each locale publishes an inclusive strict ceiling for cardinal, ordinal, and currency output.
BigInt Example β
js
import { ToWords } from 'to-words';
const tw = new ToWords({ localeCode: 'en-US' });
tw.convert(1000000000000000000n);
// "One Quintillion"
tw.convert('9007199254740993');
// "Nine Quadrillion Seven Trillion One Hundred Ninety Nine Billion..."
// Indian system
const hi = new ToWords({ localeCode: 'hi-IN' });
hi.convert(100000000000000000n);
// "ΰ€ΰ€ ΰ€Άΰ€ΰ€"String Input For Precision β
js
const tw = new ToWords({ localeCode: 'en-US' });
tw.convert('9007199254740993');
tw.convert('1000000000000000000000');Use string input when the value came from a database, finance system, or API and must remain exact.
Supported Range and Compose Mode β
js
import { getLocaleMetadata } from 'to-words/manifest';
getLocaleMetadata('en-US').range.maximumSupported.cardinal;
// exact decimal string; safe to parse as BigIntThe default rangeMode: 'strict' raises NumberOutOfRangeError above the applicable ceiling. This prevents the package from silently presenting mechanically repeated scale words as verified locale output.
Use compose mode only when that recursive behavior is explicitly acceptable:
js
tw.convert('1e100', { rangeMode: 'compose' });
tw.toOrdinal('1e100', { rangeMode: 'compose' });Compose mode preserves exact input and the legacy algorithm, but wording beyond the strict ceiling is not claimed as independently verified.
Large-Number Systems β
en-USand most western locales use short scalede-DEandfr-FRuse long scale wording such asMilliardeandMilliardhi-IN,ta-IN, andur-PKuse lakh / crore style groupingja-JP,zh-CN, andko-KRuse East Asian units such asδΈ,ε, andε
When To Use BigInt vs String β
- Use
bigintwhen your app already holds whole numbers as integers - Use
stringwhen decimal precision or trailing zeros matter - Use plain
numberonly when the value is safely within JavaScript integer limits and fractional precision is not critical