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 28, 2017
1 parent ee662ae commit d7a9e23
Show file tree
Hide file tree
Showing 11 changed files with 519 additions and 12 deletions.
7 changes: 5 additions & 2 deletions documentation/abs.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,11 @@ There are two functions which could be used, the *method function*, and the *sta

The static method function takes a parameter n and is always used as <code>BigArith.abs()</code>. It returns the absolute value of n.

If the parameter is a number, it should be between the <code>Number.MIN_SAFE_INTEGER</code> and <code>Number.MAX_SAFE_INTEGER</code> limits.
> Any number parameter (that is not strings of digits or a BigArith), it 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');` and every other thing remains the same in both server-side and client-side code.
#### Using method function

```javascript
Expand Down Expand Up @@ -66,4 +68,5 @@ More examples [here](https://github.com/osofem/BigArith.js/tree/master/examples/
* [round()](https://osofem.github.io/BigArith.js/documentation/round.html)
* [isNegative()](https://osofem.github.io/BigArith.js/documentation/isnegative.html)
* [isPositive()](https://osofem.github.io/BigArith.js/documentation/ispositive.html)
* [truncate()](https://osofem.github.io/BigArith.js/documentation/truncate.html)
* [truncate()](https://osofem.github.io/BigArith.js/documentation/truncate.html)
* [negate()](https://osofem.github.io/BigArith.js/documentation/negate.html)
11 changes: 10 additions & 1 deletion documentation/add.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,12 @@ There are two functions which could be used, the *method function*, and the *sta

The static method function takes two parameters (a, b) and is always used as <code>BigArith.add()</code>. It returns the sum of a and b.

If the parameters are numbers, it should be between the <code>Number.MIN_SAFE_INTEGER</code> and <code>Number.MAX_SAFE_INTEGER</code> limits.
> Any number parameter (that is not strings of digits or a BigArith), it 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');` and every other thing remains the same in both server-side and client-side code.
#### Using method function

```javascript
Expand All @@ -61,6 +63,13 @@ ba = BigArith.add("+17031986", "24011985"); //BigArith object with value "410439
ba = BigArith.add("8888888888888888888888888888888888888888888888888888888", "99999999999999999999999999999999999999999999999999999999999999"); //BigArith object with value "100000008888888888888888888888888888888888888888888888888888887"
```

#### Method chaining
Since the method returns a BigArith objects, [method chaining](method_chaining.html) is possible.
```javascript
var ba = new BigArith("-17031986");
ba = ba.add("+17031986").add("24011985").subtract("456785564"); //BigArith object with value "-432773579"
```

More examples [here](https://github.com/osofem/BigArith.js/tree/master/examples/)

### See also
Expand Down
9 changes: 6 additions & 3 deletions documentation/ceil.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ BigArith.ceil(n);
*none*

#### static method function
##### n - {string|number|BigArith}
##### n - Required - {string|number|BigArith}
The number to ceil. This could be a string of digits, a number, or a BigArith object.

### Return value
Expand All @@ -32,10 +32,12 @@ There are two functions which could be used, the *method function*, and the *sta

The static method function takes one parameter (n) and is always used as <code>BigArith.ceil()</code>. It returns the smallest integer greater than or equal to n.

If the parameters are numbers, it should be between the <code>Number.MIN_SAFE_INTEGER</code> and <code>Number.MAX_SAFE_INTEGER</code> limits.
> Any number parameter (that is not strings of digits or a BigArith), it 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');` and every other thing remains the same in both server-side and client-side code.
#### Using method function

```javascript
Expand Down Expand Up @@ -77,4 +79,5 @@ More examples [here](https://github.com/osofem/BigArith.js/tree/master/examples/
* [round()](https://osofem.github.io/BigArith.js/documentation/round.html)
* [isNegative()](https://osofem.github.io/BigArith.js/documentation/isnegative.html)
* [isPositive()](https://osofem.github.io/BigArith.js/documentation/ispositive.html)
* [truncate()](https://osofem.github.io/BigArith.js/documentation/truncate.html)
* [truncate()](https://osofem.github.io/BigArith.js/documentation/truncate.html)
* [negate()](https://osofem.github.io/BigArith.js/documentation/negate.html)
8 changes: 5 additions & 3 deletions documentation/compare.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,23 +26,25 @@ The number to compare with. This could be a string of digits, a number, or a Big

### Return value
#### method function - {integer}
<code>-1</code> if value of BigArith object is less to n, <code>0</code> if value of BigArith object is equal to n, <code>1</code> if value of BigArith object is greater than n
<code>-1</code> if value of BigArith object is less than n, <code>0</code> if value of BigArith object is equal to n, <code>1</code> if value of BigArith object is greater than n

#### static method function - {integer}
<code>-1</code> if a is less to b, <code>0</code> if a is equal to b, <code>1</code> if a is greater than b.
<code>-1</code> if a is less than b, <code>0</code> if a is equal to b, <code>1</code> if a is greater than 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 an integer indicating whether value of object is lesser, equals or greater than n.

The static method function takes two parameters (a, b) and is always used as <code>BigArith.compare()</code>. It returns an integer indicating whether a is lesser, equals or greater than b.

If the parameters are numbers, it should be between the <code>Number.MIN_SAFE_INTEGER</code> and <code>Number.MAX_SAFE_INTEGER</code> limits.
> Any number parameter (that is not strings of digits or a BigArith), it should be between the <code>Number.MIN_SAFE_INTEGER</code> and <code>Number.MAX_SAFE_INTEGER</code> limits.
* <code>-1</code> : BigArith object value < n or a < b.
* <code>0</code> : BigArith object value == n or a == b.
* <code>1</code> : BigArith object value > n or a > b.

### Examples
> In the server-side, always remember to add the line `var BigArith = require('bigarith.js');` and every other thing remains the same in both server-side and client-side code.
#### Using method function

```javascript
Expand Down
8 changes: 5 additions & 3 deletions documentation/compareabs.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,23 +26,25 @@ The number to compare with. This could be a string of digits, a number, or a Big

### Return value
#### method function - {integer}
<code>-1</code> if absolute value of BigArith object is less to absolute value of n, <code>0</code> if absolute value of BigArith object is equal to absolute value of n, <code>1</code> if absolute value of BigArith object is greater than absolute value of n
<code>-1</code> if absolute value of BigArith object is less than absolute value of n, <code>0</code> if absolute value of BigArith object is equal to absolute value of n, <code>1</code> if absolute value of BigArith object is greater than absolute value of n

#### static method function - {integer}
<code>-1</code> if absolute value of a is less to absolute value of b, <code>0</code> if absolute value of a is equal to absolute value of b, <code>1</code> if absolute value of a is greater than absolute value of b.
<code>-1</code> if absolute value of a is less than absolute value of b, <code>0</code> if absolute value of a is equal to absolute value of b, <code>1</code> if absolute value of a is greater than absolute value of 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 an integer indicating whether absolute value of object is lesser, equals or greater than absolute value of n.

The static method function takes two parameters (a, b) and is always used as <code>BigArith.compareAbs()</code>. It returns an integer indicating whether absolute value of a is lesser, equals or greater than absolute value of b.

If the parameters are numbers, it should be between the <code>Number.MIN_SAFE_INTEGER</code> and <code>Number.MAX_SAFE_INTEGER</code> limits.
> Any number parameter (that is not strings of digits or a BigArith), it should be between the <code>Number.MIN_SAFE_INTEGER</code> and <code>Number.MAX_SAFE_INTEGER</code> limits.
* <code>-1</code> : BigArith object absolute value < n absolute value or a absolute value < b absolute value.
* <code>0</code> : BigArith object absolute value == n absolute value or a absolute value == b absolute value.
* <code>1</code> : BigArith object absolute value > n absolute value or a absolute value > b absolute value.

### Examples
> In the server-side, always remember to add the line `var BigArith = require('bigarith.js');` and every other thing remains the same in both server-side and client-side code.
#### Using method function

```javascript
Expand Down
83 changes: 83 additions & 0 deletions documentation/divide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# divide()
<code>divide()</code> returns the quotient of the division of two numbers. There is a method function and a static method function.

#### Syntax
##### method function
```javascript
ba.divide(n);
```

##### static method function
```javascript
BigArith.divide(a, b);
```

### Parameters
#### method function
##### n - Required - {string|number|BigArith}
The divisor with the value of the BigArith object as the dividend. This could be a string of digits, a number, or a BigArith object.

#### static method function
##### a - Required - {string|number|BigArith}
The dividend: this could be a string of digits, a number, or a BigArith object.

##### b - Required - {string|number|BigArith}
The divisor: 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 quotient of the division of the value of the BigArith object it is called on (the dividend) and n (the divisor).

#### static method function - {BigArith}
A BigArith object with its value equals to the quotient of the division of a (the dividend) and b (the divisor).

##### Description
There are two functions which could be used, the *method function*, and the *static method function*. The method function takes one parameter (n) as the divisor and returns the quotient of the division of the value of the BigArith object it is called on and n.

The static method function takes two parameters (a, b) and is always used as <code>BigArith.divide()</code>. It returns the quotient of the division of a as the dividend and b as the divisor.

The quotient returned will be to maximum of 200 decimal places *when necessary*.

If n (in case of method function) or b (in case of static method function) is equivalent to zero, a <code>RangeError("Division by zero")</code> will be thrown.

> Any number parameter (that is not strings of digits or a BigArith), it 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');` and 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.divide("24011985"); //BigArith object with value "-0.70931187071789358522421199246959382991451977002317800881518125219551819643398911002151633861173909612220730605986968590893256013611536072507125087742641851558711201926871102076733764409731223803446487"

ba = new BigArith("4");
ba = ba.divide("0.5"); //BigArith object with value "8"

ba = new BigArith("8888888888888888888888888888888888888888888888888888888");
ba = ba.divide("99999999999999999999999999999999999999999999999999999999999999"); //BigArith object with value "0.00000008888888888888888888888888888888888888888888888888888888000000088888888888888888888888888888888888888888888888888888880000000888888888888888888888888888888888888888888888888888888800000008888889"
```

#### Using the static method function

```javascript
var ba = BigArith.divide("-17031986", "24011985"); //BigArith object with value "-0.70931187071789358522421199246959382991451977002317800881518125219551819643398911002151633861173909612220730605986968590893256013611536072507125087742641851558711201926871102076733764409731223803446487"
ba = BigArith.divide("4", "0.5"); //BigArith object with value "8"
ba = BigArith.divide("8888888888888888888888888888888888888888888888888888888", "99999999999999999999999999999999999999999999999999999999999999"); //BigArith object with value "0.00000008888888888888888888888888888888888888888888888888888888000000088888888888888888888888888888888888888888888888888888880000000888888888888888888888888888888888888888888888888888888800000008888889"
```

#### Method chaining
Since the method returns a BigArith objects, [method chaining](method_chaining.html) is possible.
```javascript
var ba = new BigArith("-17031986");
ba = ba.divide("+17031986").add("24011985").multiply("456785564"); //BigArith object with value "10968327654198976"
```

More examples [here](https://github.com/osofem/BigArith.js/tree/master/examples/)

### See also
* [subtract()](https://osofem.github.io/BigArith.js/documentation/subtract.html)
* [multiply()](https://osofem.github.io/BigArith.js/documentation/multiply.html)
* [add()](https://osofem.github.io/BigArith.js/documentation/add.html)
* [modulus()](https://osofem.github.io/BigArith.js/documentation/modulus.html)
84 changes: 84 additions & 0 deletions documentation/floor.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# floor()
<code>floor()</code> returns the largest integer less than or equal to a given number. There is a method function and a static method function.

#### Syntax
##### method function
```javascript
ba.floor();
```

##### static method function
```javascript
BigArith.floor(n);
```

### Parameters
#### method function
*none*

#### static method function
##### n - Required - {string|number|BigArith}
The number to floor. 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 <code>floor</code>ed value of the BigArith object it is called on.

#### static method function - {BigArith}
A BigArith object with its value equals to the <code>floor</code>ed value of n.

##### Description
There are two functions which could be used, the *method function*, and the *static method function*. The method function takes no parameter and returns a BigArith whose value equals the largest integer less than or equal to that of the BigArith object it is called on.

The static method function takes one parameter (n) and is always used as <code>BigArith.floor()</code>. It returns the largest integer less than or equal to n.

> Any number parameter (that is not strings of digits or a BigArith), it 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');` and every other thing remains the same in both server-side and client-side code.
#### Using method function

```javascript
var ba = new BigArith("-17031986.001");
ba = ba.floor(); //BigArith object with value "-17031987"

ba = new BigArith("+17031986.001");
ba = ba.floor(); //BigArith object with value "17031986"

ba = new BigArith("999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999.999");
ba = ba.floor(); //BigArith object with value "999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999"

ba = new BigArith();
ba = ba.floor(); //BigArith object with value "0"

ba = new BigArith(null);
ba = ba.floor(); //BigArith object with value "0"

ba = new BigArith(NaN);
ba = ba.floor(); //NaN
```

#### Using the static method function

```javascript
var ba = BigArith.floor("-17031986.001"); //BigArith object with value "-17031987"
ba = BigArith.floor("+17031986.001"); //BigArith object with value "17031986"
ba = BigArith.floor("999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999.999"); //BigArith object with value "999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999"
ba = BigArith.floor(); //BigArith object with value "0"
ba = BigArith.floor(null); //BigArith object with value "0"
ba = BigArith.floor(NaN); //NaN
```

More examples [here](https://github.com/osofem/BigArith.js/tree/master/examples/)

### See also
* [abs()](https://osofem.github.io/BigArith.js/documentation/abs.html)
* [ceil()](https://osofem.github.io/BigArith.js/documentation/ceil.html)
* [round()](https://osofem.github.io/BigArith.js/documentation/round.html)
* [isNegative()](https://osofem.github.io/BigArith.js/documentation/isnegative.html)
* [isPositive()](https://osofem.github.io/BigArith.js/documentation/ispositive.html)
* [truncate()](https://osofem.github.io/BigArith.js/documentation/truncate.html)
* [negate()](https://osofem.github.io/BigArith.js/documentation/negate.html)
Loading

0 comments on commit d7a9e23

Please sign in to comment.