Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mikolalysenko/robust-sequence-to-fixed-point
Turn a sequence of floats into a fixed point big integer
https://github.com/mikolalysenko/robust-sequence-to-fixed-point
Last synced: 7 days ago
JSON representation
Turn a sequence of floats into a fixed point big integer
- Host: GitHub
- URL: https://github.com/mikolalysenko/robust-sequence-to-fixed-point
- Owner: mikolalysenko
- License: mit
- Created: 2014-05-05T19:32:10.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2014-05-05T19:45:15.000Z (over 10 years ago)
- Last Synced: 2024-12-16T22:35:35.855Z (10 days ago)
- Language: JavaScript
- Size: 129 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
robust-sequence-to-fixed-point
==============================
Converts a non-overlapping increasing sequence of numbers into a fixed point big number representation.# Example
```javascript
var toFixed = require("robust-to-fixed-point")var seq = [Math.pow(2, -200), Math.pow(2, 200)]
console.log(toFixed(seq).toString(16))
```Output:
```javascript
4000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
```# Install
```
npm install robust-sequence-to-fixed-point
```# API
```javascript
var toFixed = require("robust-sequence-to-fixed-point")
```#### `toFixed(seq)`
Converts a sequence of floats into a fixed point [bignumber](https://www.npmjs.org/package/bn.js).* `seq` is a sequence of floating point values
**Returns** A fixed point big integer, with the decimal point at 2^1074.
#### `toFixed.DECIMAL_POINT`
The binary position of the decimal pointIs always `1074`
# Credits
(c) 2014 Mikola Lysenko. MIT License