Numbers in words
Integers written out in Brazilian Portuguese (por extenso).
Write out in words
- JavaScript library
- Python library
- Go library
- Ruby library
- Rust library
- .NET library2 cases fail
- Erlang library
Writes an integer in Brazilian Portuguese cardinal words ("por extenso"): for example, 1235 is "mil duzentos e trinta e cinco".
- Accepts integers from -999 999 999 999 999 to 999 999 999 999 999. The function truncates a non-integer toward zero and puts "menos" before a negative number.
options.gender("masculine"by default, or"feminine") agrees "um/uma", "dois/duas" and the hundreds ("duzentos/duzentas") with the noun the number qualifies.- The last group takes an "e" before it only when it is below 100 or a round hundred: 1200 is "mil e duzentos" and 1100 is "mil e cem", while 1235 is "mil duzentos e trinta e cinco" and 1101 is "mil cento e um".
- Returns an empty string for a value outside that range, not finite, or not a number.
- Zero is "zero", and so is any value that truncates to 0 (
-0.5, never "menos zero"). The result is always lower case. - With
"feminine", only the thousands group and the last group change (2000 is "duas mil", 21 is "vinte e uma"). The multiplier of "milhão", "bilhão" and "trilhão" stays masculine (2 000 000 is "dois milhões").
| Parameter | Type | Required |
|---|---|---|
value | number | yes |
options | ConvertNumberToWordsOptions | no |
options.gender | NumberToWordsGender | no |
| returns | string |
Write an integer in Brazilian Portuguese cardinal words ("por extenso"): 1235 becomes "mil duzentos e trinta e cinco".
- Options (
ConvertNumberToWordsOptions):gender(default"masculine") agrees "um/dois" and the hundreds ("duzentos/duzentas") with the noun the number qualifies. - Accepts integers from
-999999999999999to999999999999999(999 trillion). A non-integer is truncated toward zero. - Returns
""for a value outside that range or not finite. - The last group takes an "e" before it only when it is below 100 or a round hundred:
1200is"mil e duzentos"and1100is"mil e cem", while1235is"mil duzentos e trinta e cinco"and1101is"mil cento e um".
import { convertNumberToWords } from '@brazilian-utils/brazilian-utils';
convertNumberToWords(123); // "cento e vinte e três"
convertNumberToWords(1001); // "mil e um"
convertNumberToWords(2000000); // "dois milhões"
convertNumberToWords(-42); // "menos quarenta e dois"
convertNumberToWords(2, { gender: 'feminine' }); // "duas"
convertNumberToWords(12.9); // "doze" (truncated toward zero)
convertNumberToWords(NaN); // ""Try it with JavaScript convertNumberToWords
Shared test cases (25) and the result in each library number.convertToWords
Official sources
No official source is listed yet.
See also Currency (BRL)
Last updated on
