# Numbers in words

> Write numbers and rupee amounts in words with lakh and crore, in English or Urdu, including cheque style (“Rupees … Only”).

Source: https://pakdatakit.dev/docs/words/

`import { numberToWords, amountInWords } from 'pakdatakit/words'`

Writes numbers the way they are said in Pakistan: hundred, thousand, lakh, crore, arab and kharab, not million and billion. `amountInWords()` adds rupees and paisa, as on cheques and invoices, in English or Urdu.

## Examples

**TypeScript**

```ts
import { numberToWords, amountInWords } from 'pakdatakit';

numberToWords(12500000);
// → 'one crore twenty-five lakh'

amountInWords(125000.5);
// → 'one lakh twenty-five thousand rupees and fifty paisa'

amountInWords(125000, { cheque: true });
// → 'Rupees One Lakh Twenty-Five Thousand Only'

amountInWords(125000, { language: 'ur', cheque: true });
// → 'ایک لاکھ پچیس ہزار روپے صرف'
```

**Python**

```python
from pakdatakit import number_to_words, amount_in_words

number_to_words(12_500_000)
# → 'one crore twenty-five lakh'

amount_in_words(125000.5)
# → 'one lakh twenty-five thousand rupees and fifty paisa'

amount_in_words(125_000, cheque=True)
# → 'Rupees One Lakh Twenty-Five Thousand Only'

amount_in_words(125_000, language='ur', cheque=True)
# → 'ایک لاکھ پچیس ہزار روپے صرف'
```

**Dart**

```dart
import 'package:pakdatakit/pakdatakit.dart';

numberToWords(12500000);
// → 'one crore twenty-five lakh'

amountInWords(125000.5);
// → 'one lakh twenty-five thousand rupees and fifty paisa'

amountInWords(125000, cheque: true);
// → 'Rupees One Lakh Twenty-Five Thousand Only'

amountInWords(125000, language: WordsLanguage.ur, cheque: true);
// → 'ایک لاکھ پچیس ہزار روپے صرف'
```

**C#**

```csharp
using PakDataKit;

Words.NumberToWords(12500000);
// → "one crore twenty-five lakh"

Words.AmountInWords(125000.5);
// → "one lakh twenty-five thousand rupees and fifty paisa"

Words.AmountInWords(125000, WordsLanguage.En, cheque: true);
// → "Rupees One Lakh Twenty-Five Thousand Only"

Words.AmountInWords(125000, WordsLanguage.Ur, cheque: true);
// → "ایک لاکھ پچیس ہزار روپے صرف"
```

**PHP**

```php
use PakDataKit\Words;

Words::numberToWords(12_500_000);
// → 'one crore twenty-five lakh'

Words::amountInWords(125000.5);
// → 'one lakh twenty-five thousand rupees and fifty paisa'

Words::amountInWords(125_000, 'en', cheque: true);
// → 'Rupees One Lakh Twenty-Five Thousand Only'

Words::amountInWords(125_000, 'ur', cheque: true);
// → 'ایک لاکھ پچیس ہزار روپے صرف'
```

## Reference

### numberToWords()

```ts
function numberToWords(n: number, options?: NumberToWordsOptions): string;

type WordsLanguage = 'en' | 'ur';

interface NumberToWordsOptions {
  language?: WordsLanguage; // default 'en'
}
```

**Parameters.** `n`: a safe integer; negative numbers start with `minus` (<span lang="ur" dir="rtl">منفی</span> in Urdu). `options.language`: `'en'` (the default) or `'ur'`.

**Returns** the number in words: `numberToWords(125000)` is `"one lakh twenty-five thousand"`, and in Urdu <span lang="ur" dir="rtl">ایک لاکھ پچیس ہزار</span>.

**Caveats.** Throws a `RangeError` if `n` is not a safe integer, or if `language` is not `'en'` or `'ur'`. In Urdu, every number from 0 to 99 has a word of its own (<span lang="ur" dir="rtl">پچیس</span> for 25), not tens plus ones.

**Related:** [`amountInWords()`](#amountinwords).

### amountInWords()

```ts
function amountInWords(amount: number, options?: AmountInWordsOptions): string;

interface AmountInWordsOptions {
  language?: WordsLanguage; // default 'en'
  cheque?: boolean;
}
```

**Parameters.** `amount`: in PKR, zero or more. `options.language`: `'en'` or `'ur'`. `options.cheque`: cheque style, `"Rupees One Lakh Twenty-Five Thousand Only"` in English, or the words followed by <span lang="ur" dir="rtl">روپے صرف</span> in Urdu.

**Returns** the amount in words, with paisa: `amountInWords(125000.5)` is `"one lakh twenty-five thousand rupees and fifty paisa"`.

**Caveats.** Amounts are rounded to the nearest paisa. Throws a `RangeError` if `amount` is negative, not finite or too large.

**Related:** [`numberToWords()`](#numbertowords), [rupee formatting](https://pakdatakit.dev/docs/format/) for `Rs. 150,000` and `25 Lakh`.

## Related

- [TypeScript API reference for `pakdatakit/words`](https://pakdatakit.dev/api/typescript/words/)
- [Rupee formatting](https://pakdatakit.dev/docs/format/)
- [Urdu and text](https://pakdatakit.dev/docs/text/) for Urdu digits
