Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
osofem authored Jun 30, 2017
1 parent 4f71b91 commit 967201b
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 13 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,14 @@
* Added squareRoot() [unstable]

### v0.0.2
#### Released - 30th June, 2017
* Fixed some bugs
* change max() to accept any length of arguments
* change min() to accept any length of arguments

### v0.0.3
* make max and min accept mixture of numbers and arrays e.g. max(1, 2, 3, [4, 5, 6])
* Added power
* Added sin()
* Added cos()
* Added tan()
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
## Welcome to bigarith.js
[![Join the chat at https://gitter.im/BigArith-js/Lobby](https://badges.gitter.im/BigArith-js/Lobby.svg)](https://gitter.im/BigArith-js/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)

`bigarith.js` offers a way to handles **very large numbers** (be it integers, fractionals, strings of digits, strings of english words) to precision. bigarith is from the words <b>big arith</b>metic.
`bigarith.js` offers a way to handles **very large numbers** (be it integers, fractionals, strings of digits, strings of english words) to precision. bigarith is from the words **big arith**metic.

### Install
Depending on the environment in which bigarith.js will be used, it can be installed via:
Expand All @@ -14,7 +14,7 @@ Server-side usage

Client-side usage
1. Including the library from the rawgit.com CDN.<br>
You can do that by adding <code>&lt;script src=&quot;https&#58;&#47;&#47;cdn.rawgit.com/osofem/bigarith.js/&lt;version tag&gt;/bigarith.js&quot;&gt;&lt;/script&gt;</code> to your code. Replace <code>&lt;version tag&gt;</code> with the version targetted e.g. <code>v1.0</code>. Check [versions](https://github.com/osofem/bigarith.js/tags) for the latest version (the latest version is always recommended).
You can do that by adding <code>&lt;script src=&quot;https&#58;&#47;&#47;cdn.rawgit.com/osofem/bigarith.js/&lt;version tag&gt;/bigarith.js&quot;&gt;&lt;/script&gt;</code> to your code. Replace <code>&lt;version tag&gt;</code> with the version targetted e.g. <code>v1.0.0</code>. Check [versions](https://github.com/osofem/bigarith.js/tags) for the latest version (the latest version is always recommended).
2. Downloading the source from GitHub.com<br>
You can also download bigarith.js from [releases](https://github.com/osofem/bigarith.js/releases/) on github.com (the latest version is always recommended). Extract the files and include the bigarith.js file in your work.

Expand All @@ -38,7 +38,7 @@ var ba = new BigArith(null); //initialize ba to a BigArith object of value "0"
var ba = new BigArith(); //initialize ba to a BigArith object of value "0"
var ba = new BigArith(null); //initialize ba to a BigArith object of value "0"
```
This simply initialize the variable <code>ba</code> to a <code>BigArith</code> object of value <code>"0"</code>.
This simply initialize the variable <code>ba</code> to a `BigArith` object of value <code>"0"</code>.

##### 2. Initiating with a number
###### Server-side
Expand All @@ -51,9 +51,9 @@ var ba = new BigArith(12345); //initialize ba to a BigArith object of value "123
```javascript
var ba = new BigArith(12345); //initialize ba to a BigArith object of value "12345"
```
The number must be between the <code>Number.MIN_SAFE_INTEGER</code> (-9007199254740991) and <code>Number.MAX_SAFE_INTEGER</code> (9007199254740991) limits else a <code>RangeError</code> will be thrown. <em>Please note that only integers are recommended for this method</em> because of the floating point precision _problem_ in JavaScript (with is one of the problems BigArith.js aim at solving).
The number must be between the <code>Number.MIN_SAFE_INTEGER</code> (-9007199254740991) and <code>Number.MAX_SAFE_INTEGER</code> (9007199254740991) limits else a <code>RangeError</code> will be thrown. <em>Please note that only integers are recommended for this method</em> because of the floating point precision _problem_ in JavaScript (with is one of the problems bigarith.js aim at solving).

Doing <code>var ba = new BigArith(0.45);</code> might still be considered _"safe"_ but some can be tempted to do <code>var ba = new BigArith(0.1 \* 0.2);</code>. As it is known <code>0.1 \* 0.2</code> will not give <code>0.02</code> in JavaScript but rather <code>0.020000000000000004</code>. Therefore, it is better to avoid initializing fractional numbers this way all together.
Doing <code>var ba = new BigArith(0.45);</code> might still be considered _"safe"_ but some could be tempted to do <code>var ba = new BigArith(0.1\*0.2);</code>. As it is known <code>0.1\*0.2</code> will not give <code>0.02</code> in JavaScript but rather <code>0.020000000000000004</code>. Therefore, it is better to avoid initializing fractional numbers this way all together.

> It is recommended fractional numbers are initialized with strings.
> See [here](#init_string).
Expand Down Expand Up @@ -101,7 +101,7 @@ var bd = new BigArith("point two three seven"); //initialize bd to a BigArith ob

A negative number <em>should</em> start with the word <code>"negative"</code>, a positive number can start with the "postive" word but this can be outrightly omitted. The mantissa part <em>should be spelt out</em> after the word <code>point</code> or else the word will evaluate to <code>NaN</code>.

This is case insensitive and only [Short Scale](short_scales.html) naming system is supported.
This is case insensitive and only [Short Scale](https://osofem.github.io/bigarith.js/documentation/short_scales.html) naming system is supported.

```javascript
var ba = new BigArith("three point one two"); // This evaluate to "3.12"
Expand All @@ -118,7 +118,7 @@ var ba = new BigArith("PI"); // this evaluate to "3.1415926535897932384626433832
```javascript
var ba = new BigArith("PI"); // this evaluate to "3.14159265358979323846264338327950288419716939937510582097494459230781640628620899862803482534211706798214808651328230664709384460955058223172535940812848111745028410270193852110555964462294895493038196"
```
`bigarith.js` has a list of inbuilt constants which can be used for initialization. Check [here](documentation/list_constant.html) for the updated list.
`bigarith.js` has a list of inbuilt constants which can be used for initialization. Check [here](https://osofem.github.io/bigarith.js/documentation/list_constants.html) for the updated list.

##### 6. Initiating with a BigArith object
###### Server-side
Expand Down Expand Up @@ -155,7 +155,7 @@ console.log(ba.valueOf());//this outputs -5637865.32 to the console

#### toWords() method
The <code>toWords</code> method returns the value of the BigArith object in English words using the [Short Scale](https://osofem.github.io/bigarith.js/documentation/short_scales.html) naming system. If the length of the object's characteristic part (part before the decimal point) is greater than 1,005 or the length of the mantissa part (part after the decimal point) is greater than 200, a <code>RangeError</code> is thrown.
The <code>toWords</code> method returns the value of the BigArith object in English words using the [Short Scale](https://osofem.github.io/bigarith.js/documentation/short_scales.html) naming system. If the length of the object's characteristic part (part before the decimal point) is greater than 1,005 or the length of the mantissa part (part after the decimal point) is greater than 200, a `RangeError` is thrown.
```javascript
var ba = new BigArith(1e3);
console.log(ba.toWords());//this outputs "one thousand" to the console
Expand All @@ -181,7 +181,7 @@ See also:
17. [randomInt()](https://osofem.github.io/bigarith.js/documentation/randomint.html)
18. [round()](https://osofem.github.io/bigarith.js/documentation/round.html)
19. [square()](https://osofem.github.io/bigarith.js/documentation/square.html)
20. [squareRoot()](https://osofem.github.io/bigarith.js/documentation/squareroot.html)
20. [squareRoot()](https://osofem.github.io/bigarith.js/documentation/squareroot.html) [unstable]
21. [subtract()](https://osofem.github.io/bigarith.js/documentation/subtract.html)
22. [toFixed()](https://osofem.github.io/bigarith.js/documentation/tofixed.html)
23. [toWords()](https://osofem.github.io/bigarith.js/documentation/towords.html)
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"name": "bigarith.js",
"version": "0.0.1",
"version": "0.0.2",
"description": "Do very large math!",
"main": "BigArith.js",
"main": "bigarith.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "https://github.com/osofem/BigArith.js/"
"url": "https://github.com/osofem/bigarith.js/"
},
"keywords": [
"math",
Expand All @@ -18,6 +18,6 @@
"bigmath",
"arbitrary-precision"
],
"author": "Oso Oluwafemi <osofem87@gmail.com> (https://osofem.github.io/BigArith.js/)",
"author": "Oso Oluwafemi <osofem87@gmail.com> (https://github.com/osofem)",
"license": "Apache-2.0"
}

0 comments on commit 967201b

Please sign in to comment.