# number-string-representation

> Take a decimal number and convert it to its string representation

Latest version **0.1.9** (published 2013-06-18) · BSD license · 0 weekly downloads

## Install

```sh
npm install number-string-representation
pnpm add number-string-representation
yarn add number-string-representation
bun add number-string-representation
```

Provides the command `number-string-representation`.

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.9 |
| Published | 2013-06-18 |
| First published | 2013-06-17 |
| Weekly downloads | 0 |
| License | BSD |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Noah Isaacson |
| Maintainers | clewfirst |
| Keywords | number, string, representation, check, stringify |

## Links

- npm: https://www.npmjs.com/package/number-string-representation
- Repository: https://github.com/nisaacson/number-string-representation
- Issues: https://github.com/nisaacson/number-string-representation/issues
- npm.io page: https://npm.io/package/number-string-representation

## Dependencies (1)

- [optimist](https://npm.io/package/optimist.md) ~0.5.2

## Alternatives

- [random-seedable](https://npm.io/package/random-seedable.md) — 27.9K weekly downloads
- [n2words](https://npm.io/package/n2words.md) — 22.2K weekly downloads
- [@stdlib/math-base-special-factorialln](https://npm.io/package/@stdlib/math-base-special-factorialln.md) — 5.7K weekly downloads
- [@stdlib/math-base-special-abs2](https://npm.io/package/@stdlib/math-base-special-abs2.md) — 1.7K weekly downloads
- [commons-math-interpolation](https://npm.io/package/commons-math-interpolation.md) — 1.4K weekly downloads

## Recent versions

- 0.1.9 (latest) — 2013-06-18
- 0.1.8 — 2013-06-18
- 0.1.7 — 2013-06-18
- 0.1.6 — 2013-06-18
- 0.1.5 — 2013-06-17
- 0.1.4 — 2013-06-17
- 0.1.3 — 2013-06-17
- 0.1.2 — 2013-06-17
- 0.1.1 — 2013-06-17
- 0.1.0 — 2013-06-17
- 0.0.2 — 2013-06-17
- 0.0.1 — 2013-06-17

## README

# Number String Representation

[![Build Status](https://travis-ci.org/nisaacson/number-string-representation.png)](https://travis-ci.org/nisaacson/number-string-representation)
[![Dependency Status](https://david-dm.org/nisaacson/number-string-representation.png)](https://david-dm.org/nisaacson/number-string-representation)

Take a decimal number and convert it to a string representation. For example if you have the number `2523.04`, this module will convert `2523.04` to `"Two thousand five hundred twenty-three and 04/100 dollars"`

# Installation

```bash
npm install -g number-string-representation
```

# Requirements
The module requires that you have the `node` and `npm` binaries installed and available on your path. The latest version node.js is available [here](http://nodejs.org/download/) and includes the npm binary as well

# Usage

The module can be used either as a stand-alone command line tool or within other javascript code. The module has only been tested on node.js versions 0.8 & 0.10 but should work in the browser without issues


As a command line tool
```bash
number-string-representation --number="2523.04"
# outputs "Two thousand five hundred twenty-three and 04/100 dollars"
```

For usage of the command line tool execute the command with no option parameters specified

```bash
number-string-representation
# prints out usage information
```

As a module within your own code. Note that you must pass a valid number as the input parameter to module function. String numbers will throw an exception

Valid input parameter example

```javascript
var numberStringRepresentation = require('number-string-representation')
var input = 2523.04
var output = numberStringRepresentation(input)
console.log('output: %s', output)
```


Invalid input parameter example
```javascript
var numberStringRepresentation = require('number-string-representation')
var input = '2523.04'
var output = numberStringRepresentation(input) // will throw an error here
console.log('output: %s', output)
```

# Negative numbers
If you supply a negative number as an input, the output will be prepended with the text 'Negative '

```javascript
var numberStringRepresentation = require('number-string-representation')
var input = -2523.04

// output === 'Negative two thousand five hundred twenty-three and 04/100 dollars'
Ne output = numberStringRepresentation(input)
console.log('output: %s', output)
```

When using negative numbers with the command line tool, you must pass them using both the equals sign and quotation marks around your value

```bash
number-string-representation --number="-2523.04"
# outputs "Negative two thousand five hundred twenty-three and 04/100 dollars"
```

The following will not work and will instead throw an error. Note that the equals sign from the example above is missing here:
```bash
number-string-representation --number "-2523.04"
```

# Limitations

Currently the module only supports numbers in the range [-999999999999999, 999999999999999], which corresponds to negative trillions to positive trillions.

If you input a number with fractional cents, they will always be rounded down. For example

```bash
number-string-representation --number=".546"
# will output "Zero and 54/100 dollars"
```

# Test

```bash
# install the development dependencies
npm install
# run the tests
npm test
```

---
_Source: https://npm.io/package/number-string-representation · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
