Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/swashcap/scino
Format numbers in scientific notation.
https://github.com/swashcap/scino
Last synced: about 2 months ago
JSON representation
Format numbers in scientific notation.
- Host: GitHub
- URL: https://github.com/swashcap/scino
- Owner: swashcap
- License: mit
- Created: 2017-01-19T03:32:39.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2017-01-20T20:46:11.000Z (about 8 years ago)
- Last Synced: 2024-12-10T22:14:37.444Z (2 months ago)
- Language: JavaScript
- Size: 5.86 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Scino
_Format numbers in scientific notation!_
## Installation
```shell
npm install scino --save
```## Use
Simply `require` scino in your program:
```js
var scino = require('scino')
```(You’ll need to use a module bundler like [browserify](https://github.com/substack/node-browserify#readme) to use scino in a browser.)
Scino is a function that has three parameters:
### scino(num[, precision][, options])
* **`num`** ``: Number to convert to scientific notation
* **`precision`** ``: Optional precision to apply to the float
* **`options`** ``: Optional formatting optionsAt its most basic, scino formats numbers:
```js
var formatted = scino(0.0012345)
console.log(formatted) // => '1.2345 × 10⁻³'
```The numbers’ precision can be easily adjusted:
```js
var formatted = scino(0.00051927528, 4)
console.log(formatted) // => '5.193 × 10⁻⁴'
```Formatting options are also available:
```js
var formatted = scino(-1234.56, {
beforeCoefficient: '',
afterCoefficient: '',
multiplicationSign: '✖︎',
beforeExponent: '',
afterExponent: ''
})
console.log(formatted) // => '-1.23456 ✖︎ 10³'
```## License
MIT. See [LICENSE](./LICENSE) for details.