-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
560 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# square() | ||
`square()` returns the square of a number. This has only a method function. | ||
|
||
#### Syntax | ||
##### method function | ||
```javascript | ||
ba.square(); | ||
``` | ||
|
||
### Parameters | ||
#### method function | ||
*none* | ||
|
||
### Return value | ||
#### method function - {BigArith} | ||
A BigArith object with its value equals to the square of the value of the BigArith object it is called on. | ||
|
||
### Description | ||
There is no static method function for `square()` so it should ALWAYS be used as a member function. | ||
|
||
|
||
### Examples | ||
> In the server-side, always remember to add the line `var BigArith = require('bigarith.js');` however every other thing remains the same in both server-side and client-side code. | ||
#### Using method function | ||
```javascript | ||
var ba = new BigArith("-45.456"); | ||
ba = ba.square(); //BigArith object with value "2066.247936" | ||
|
||
ba = new BigArith("45.5"); | ||
ba = ba.square(); //BigArith object with value "2070.25" | ||
|
||
ba = new BigArith("2"); | ||
ba = ba.square(); //BigArith object with value "4" | ||
|
||
ba = new BigArith("3"); | ||
ba = ba.square(); //BigArith object with value "9" | ||
``` | ||
|
||
#### Method chaining | ||
Since the method returns a BigArith object, [method chaining](method_chaining.html) is possible. | ||
```javascript | ||
var ba = new BigArith("-17031986"); | ||
ba = ba.divide("+17031986").add("24011985").multiply("456785564").subtract("2"); //BigArith object with value "10968327654198974" | ||
``` | ||
``` | ||
More examples [here](https://github.com/osofem/bigarith.js/tree/master/examples/). Full documentation [here](https://github.com/osofem/bigarith.js/tree/master/documentation) | ||
### See also | ||
* [squareRoot()](https://osofem.github.io/bigarith.js/documentation/squareroot.html) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
# squareRoot() [UNSTABLE] | ||
|
||
> This function is still unstable and in the developmental stage. It takes about `16,309` milliseconds to compute squareroot 2 to two hundred decimal places on a Windows 8 with 2GB RAM, 1.8GHz processor (Google Chrome 58.0.3029.81). Additionally, it does not work with very large numbers _yet!_. | ||
`squareRoot()` returns the square root of a number. This has only a method function. | ||
|
||
#### Syntax | ||
##### method function | ||
```javascript | ||
ba.squareRoot(); | ||
``` | ||
|
||
### Parameters | ||
#### method function | ||
*none* | ||
|
||
### Return value | ||
#### method function - {BigArith} | ||
A BigArith object with its value equals to the square root of the value of the BigArith object it is called on *to 200 decimal place when necessary*. | ||
|
||
### Description | ||
There is no static method function for `squareRoot()` so it should ALWAYS be used as a member function. | ||
|
||
Negative number returns NaN. | ||
|
||
|
||
### Examples | ||
> In the server-side, always remember to add the line `var BigArith = require('bigarith.js');` however every other thing remains the same in both server-side and client-side code. | ||
#### Using method function | ||
```javascript | ||
var ba = new BigArith("2"); | ||
ba = ba.squareRoot(); //BigArith object with value "1.41421356237309504880168872420969807856967187537694807317667973799073247846210703885038753432764157273501384623091229702492483605585073721264412149709993583141322266592750559275579995050115278206057147" | ||
|
||
ba = new BigArith("0.5"); | ||
ba = ba.squareRoot(); //BigArith object with value "0.70710678118654752440084436210484903928483593768847403658833986899536623923105351942519376716382078636750692311545614851246241802792536860632206074854996791570661133296375279637789997525057639103028574" | ||
|
||
ba = new BigArith("4"); | ||
ba = ba.squareRoot(); //BigArith object with value "2" | ||
|
||
ba = new BigArith("-3"); | ||
ba = ba.squareRoot(); //NaN | ||
``` | ||
|
||
#### Method chaining | ||
Since the method returns a BigArith object, [method chaining](method_chaining.html) is possible. | ||
```javascript | ||
var ba = new BigArith("-17031986"); | ||
ba = ba.divide("+17031986").add("24011985").multiply("456785564").subtract("2"); //BigArith object with value "10968327654198974" | ||
``` | ||
``` | ||
More examples [here](https://github.com/osofem/bigarith.js/tree/master/examples/). Full documentation [here](https://github.com/osofem/bigarith.js/tree/master/documentation) | ||
### See also | ||
* [square()](https://osofem.github.io/bigarith.js/documentation/square.html) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
# subtract() | ||
<code>subtract()</code> returns the difference of two numbers. There is a method function and a static method function. | ||
|
||
#### Syntax | ||
##### method function | ||
```javascript | ||
ba.subtract(n); | ||
``` | ||
|
||
##### static method function | ||
```javascript | ||
BigArith.subtract(a, b); | ||
``` | ||
|
||
### Parameters | ||
#### method function | ||
##### n - Required - {string|number|BigArith} | ||
A subtrahend with the value of the BigArith object `add()` is called on as the minuend. This could be a string of digits, a number, or a BigArith object. | ||
|
||
#### static method function | ||
##### a - Required - {string|number|BigArith} | ||
The Minuend: this could be a string of digits, a number, or a BigArith object. | ||
|
||
##### b - Required - {string|number|BigArith} | ||
The Subtrahend: this could be a string of digits, a number, or a BigArith object. | ||
|
||
### Return value | ||
#### method function - {BigArith} | ||
A BigArith object with its value equals to the difference between the value of the BigArith object it is called on and n. | ||
|
||
#### static method function - {BigArith} | ||
A BigArith object with its value equals to the difference between a and b. | ||
|
||
### Description | ||
There are two functions which could be used, the *method function*, and the *static method function*. The method function takes one parameter (n) and returns the difference between the value of the BigArith object it is called on and the parameter. | ||
|
||
The static method function takes two parameters (a, b) and is always used as `BigArith.subtract()`. It returns the difference between a and b. | ||
|
||
> Any number parameter (that is not strings of digits or a BigArith) should be between the <code>Number.MIN_SAFE_INTEGER</code> and <code>Number.MAX_SAFE_INTEGER</code> limits. | ||
|
||
### Examples | ||
> In the server-side, always remember to add the line `var BigArith = require('bigarith.js');` however every other thing remains the same in both server-side and client-side code. | ||
#### Using method function | ||
|
||
```javascript | ||
var ba = new BigArith("-17031986"); | ||
ba = ba.subtract("24011985"); //BigArith object with value "-41043971" | ||
|
||
ba = new BigArith("+17031986"); | ||
ba = ba.subtract("24011985"); //BigArith object with value "-6979999" | ||
|
||
ba = new BigArith("3"); | ||
ba = ba.subtract("2"); //BigArith object with value "1" | ||
|
||
ba = new BigArith("-3"); | ||
ba = ba.subtract("2"); //BigArith object with value "-5" | ||
|
||
ba = new BigArith("3"); | ||
ba = ba.subtract("-2"); //BigArith object with value "5" | ||
|
||
ba = new BigArith("8888888888888888888888888888888888888888888888888888888"); | ||
ba = ba.subtract("99999999999999999999999999999999999999999999999999999999999999"); //BigArith object with value "-99999991111111111111111111111111111111111111111111111111111111" | ||
|
||
ba = new BigArith("3"); | ||
ba = ba.subtract(NaN); //NaN | ||
``` | ||
|
||
#### Using the static method function | ||
```javascript | ||
var ba = BigArith.subtract("-17031986", "24011985"); //BigArith object with value "-41043971" | ||
ba = BigArith.subtract("+17031986", "24011985"); //BigArith object with value "-6979999" | ||
ba = BigArith.subtract("3", "2"); //BigArith object with value "1" | ||
ba = BigArith.subtract("-3", "2"); //BigArith object with value "-5" | ||
ba = BigArith.subtract("3", "-2"); //BigArith object with value "5" | ||
ba = BigArith.subtract("8888888888888888888888888888888888888888888888888888888", "99999999999999999999999999999999999999999999999999999999999999"); //BigArith object with value "-99999991111111111111111111111111111111111111111111111111111111" | ||
ba = BigArith.subtract("3", NaN); //NaN | ||
``` | ||
|
||
#### Method chaining | ||
Since the method returns a BigArith object, [method chaining](method_chaining.html) is possible. | ||
```javascript | ||
var ba = new BigArith("-17031986"); | ||
ba = ba.divide("+17031986").add("24011985").multiply("456785564").subtract("2"); //BigArith object with value "10968327654198974" | ||
``` | ||
|
||
More examples [here](https://github.com/osofem/bigarith.js/tree/master/examples/). Full documentation [here](https://github.com/osofem/bigarith.js/tree/master/documentation) | ||
|
||
### See also | ||
* [add()](https://osofem.github.io/bigarith.js/documentation/add.html) | ||
* [multiply()](https://osofem.github.io/bigarith.js/documentation/multiply.html) | ||
* [divide()](https://osofem.github.io/bigarith.js/documentation/divide.html) | ||
* [modulus()](https://osofem.github.io/bigarith.js/documentation/modulus.html) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# toString() | ||
`toString()` returns the value of the BigArith object as a strings of digits. | ||
|
||
#### Syntax | ||
##### method function | ||
```javascript | ||
ba.toString(); | ||
``` | ||
|
||
### Parameters | ||
#### method function | ||
*none* | ||
|
||
### Return value | ||
#### method function - {string} | ||
Returns the value of the BigArith object as a strings of digits. | ||
|
||
### Description | ||
If the value of the BigArith object evaluate to NaN, NaN is returned. | ||
|
||
### Examples | ||
> In the server-side, always remember to add the line `var BigArith = require('bigarith.js');` however every other thing remains the same in both server-side and client-side code. | ||
#### Using method function | ||
```javascript | ||
var ba = new BigArith(1000); | ||
console.log(ba.toString()); //logs "1000" to console | ||
|
||
ba = new BigArith(1e3); | ||
console.log(ba.toString()); //logs "1000" to console | ||
|
||
ba = new BigArith("1000"); | ||
console.log(ba.toString()); //logs "1000" to console | ||
|
||
ba = new BigArith("one thousand"); | ||
console.log(ba.toString()); //logs "1000" to console | ||
|
||
ba = new BigArith(); | ||
console.log(ba.toString()); //logs "0" to console | ||
|
||
ba = new BigArith(NaN); | ||
console.log(ba.toString()); //logs NaN to console | ||
``` | ||
|
||
More examples [here](https://github.com/osofem/bigarith.js/tree/master/examples/). Full documentation [here](https://github.com/osofem/bigarith.js/tree/master/documentation) | ||
|
||
### See also | ||
* [toFixed()](https://osofem.github.io/bigarith.js/documentation/tofixed.html) | ||
* [valueOf()](https://osofem.github.io/bigarith.js/documentation/valueof.html) | ||
* [toWords()](https://osofem.github.io/bigarith.js/documentation/towords.html) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# toWords() | ||
`toWords()` 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. | ||
|
||
#### Syntax | ||
##### method function | ||
```javascript | ||
ba.toWords(); | ||
``` | ||
|
||
### Parameters | ||
#### method function | ||
*none* | ||
|
||
### Return value | ||
#### method function - {string} | ||
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. | ||
|
||
### Description | ||
If the value of the BigArith object evaluate to NaN, NaN is returned. | ||
|
||
>This function has a limit of (±1x10^1,005)-0.0000{insert 195 more zeroes}01 (i.e. nine hundred and ninety nine trecentretrigintillion point nine nine nine nine nine {insert 195 more "nine"'s}). | ||
That is 1,005 length of characteristic (parts before the decimal point) and 200 length of mantissa (parts after the decimal point). If the limit is exceeded, a RangeError is thrown. | ||
|
||
### Examples | ||
> In the server-side, always remember to add the line `var BigArith = require('bigarith.js');` however every other thing remains the same in both server-side and client-side code. | ||
#### Using method function | ||
```javascript | ||
var ba = new BigArith(1000); | ||
console.log(ba.toWords()); //logs "one thousand" to console | ||
|
||
ba = new BigArith(1e3); | ||
console.log(ba.toWords()); //logs "one thousand" to console | ||
|
||
ba = new BigArith("1000"); | ||
console.log(ba.toWords()); //logs "one thousand" to console | ||
|
||
ba = new BigArith("one thousand"); | ||
console.log(ba.toWords()); //logs "one thousand" to console | ||
|
||
ba = new BigArith("-1002.789"); | ||
console.log(ba.toWords()); //logs "negative one thousand two point seven eight nine" to console | ||
|
||
ba = new BigArith(); | ||
console.log(ba.toWords()); //logs "zero" to console | ||
|
||
ba = new BigArith(NaN); | ||
console.log(ba.toWords()); //logs NaN to console | ||
``` | ||
|
||
More examples [here](https://github.com/osofem/bigarith.js/tree/master/examples/). Full documentation [here](https://github.com/osofem/bigarith.js/tree/master/documentation) | ||
|
||
### See also | ||
* [toFixed()](https://osofem.github.io/bigarith.js/documentation/tofixed.html) | ||
* [valueOf()](https://osofem.github.io/bigarith.js/documentation/valueof.html) | ||
* [toString()](https://osofem.github.io/bigarith.js/documentation/tostring.html) |
Oops, something went wrong.