Skip to content

Commit 20f9437

Browse files
committed
Improve readme and bump version.
1 parent 0a74184 commit 20f9437

2 files changed

Lines changed: 37 additions & 10 deletions

File tree

README.md

Lines changed: 36 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,45 @@ bigfloat
66
`bigfloat` is a fast arbitrary precision math library optimized for computational geometry and geoinformatics.
77
It provides base 2 floating point:
88

9-
- addition
10-
- subtraction
11-
- multiplication
12-
- comparison
13-
- conversion from JavaScript number type
14-
- conversion to string in base 2, 10 or 16
9+
- conversion from JavaScript number type `x = new BigFloat(123.456)`
10+
- addition `x.add(y)`
11+
- subtraction `x.sub(y)`
12+
- multiplication `x.mul(y)`
13+
- comparison `x.deltaFrom(y)`
14+
- conversion to string in base 2, 10 or 16 `x.toString(10)`
1515

16-
without ever losing any significant bits.
16+
without ever losing any significant bits. Numbers are immutable, so all operations return a new BigFloat.
1717

18-
Internally numbers are represented in 32-bit limbs somewhat like in the [GMP](https://gmplib.org/manual/Float-Internals.html) library.
18+
Internally numbers are represented in 32-bit limbs (digits in base 2^32) somewhat like in the [GMP](https://gmplib.org/manual/Float-Internals.html) library. The least significant limb is stored first, because basic algorithms for arithmetic operations progress from the least to most significant digit while propagating carry. If carry causes the output to grow, adding a new limb at the end of the array is faster than adding it in the beginning.
1919

20-
`bigfloat` is optimized for exponents relatively close to zero.
20+
`bigfloat` is optimized for exponents relatively close to zero, so the location of the decimal point is always present in the limb array, even if that introduces otherwise insignificant leading or trailing zero digits.
21+
22+
Getting started
23+
---
24+
25+
```bash
26+
git clone https://github.com/charto/bigfloat.git node_modules/bigfloat
27+
cd node_modules/bigfloat && npm install
28+
cd ../..
29+
node
30+
```
31+
32+
OR
33+
34+
```bash
35+
npm install bigfloat
36+
node
37+
```
38+
39+
THEN
40+
41+
```js
42+
x = Math.pow(2, 53);
43+
console.log(x + 1 - x); // Prints 0
44+
45+
BigFloat = require('bigfloat').BigFloat;
46+
console.log(new BigFloat(x).add(1).sub(x).toString()); // Prints 1
47+
```
2148

2249
License
2350
===

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "bigfloat",
3-
"version": "0.0.1",
3+
"version": "0.0.2",
44
"description": "Fast arbitrary precision math library for computational geometry.",
55
"main": "dist/bigfloat.js",
66
"typings": "dist/bigfloat.d.ts",

0 commit comments

Comments
 (0)