# two-sum

> Computes a non-overlapping sequence representing the sum of two floating point numbers.

Latest version **1.0.0** (published 2014-04-27) · MIT license · 0 weekly downloads

## Install

```sh
npm install two-sum
pnpm add two-sum
yarn add two-sum
bun add two-sum
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2014-04-27 |
| First published | 2013-09-18 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Mikola Lysenko |
| Maintainers | mikolalysenko |
| Keywords | two, sum, floating, point, robust, exact |

## Links

- npm: https://www.npmjs.com/package/two-sum
- Repository: https://github.com/mikolalysenko/two-sum
- Issues: https://github.com/mikolalysenko/two-sum/issues
- npm.io page: https://npm.io/package/two-sum

## Recent versions

- 1.0.0 (latest) — 2014-04-27
- 0.1.0 — 2013-09-18
- 0.0.0 — 2013-09-18

## README

two-sum
=======
Computes the sum of two floating point numbers as a non-overlapping sequence using Knuth's method.

* D.E. Knuth.  "The Art of Computer Programming: Seminumerical Algorithms".  Volume 2.  1981

## Install
Using npm:

		npm install two-sum


## Example

```javascript
var twoSum = require("two-sum")

//Add two wildly different sized floats
var result = twoSum(1e64, 1e-64)
console.log(result)

//Prints:
//  [1e-64, 1e64]
```

## API

### `require("two-sum")(a, b[, result])`
Computes a non-overlapping sequence representing the sum of a and b.

* `a` is a number
* `b` is a number
* `result` is an optional length 2 array encoding the result of the sum of `a` and `b`

**Returns** A length 2 array representing the non-overlapping sequence encoding the sum of a and b.  The first term has smaller magnitude than the second.

## Credits
Based on an idea from JRS robust geometric predicates paper.

Implementation (c) 2013 Mikola Lysenko.  MIT License

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