You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
34
35
@@ -215,11 +216,24 @@ var product = n1.multiply(n2); // product = new bigDecimal('-0.000169')
215
216
### divide(dividend, divisor, precision)
216
217
Divide two numbers. Pass arguments as `string` if calling on bigDecimal or pass an instance of bigDecimal if calling on object. `precision` is an optional parameter with default value of 8.
217
218
```javascript
218
-
var quotient =bigDecimal.divide('45', '4', 2); // quotient = 11.25
219
+
var quotient =bigDecimal.divide('45', '4', 2); // quotient = '11.25'
219
220
```
220
221
Alternately, use the instance property. It returns the result as new `bigDecimal`.
221
222
```javascript
222
223
var n1 =newbigDecimal('45');
223
224
var n2 =newbigDecimal('4');
224
225
var quotient =n1.divide(n2); // quotient = new bigDecimal('11.25')
225
226
```
227
+
228
+
### modulus(dividend, divisor)
229
+
Get the modulus of two numbers, i.e., remainder when the dividend is divided by the divisor. Note that both divisor and dividend need to be integers.
230
+
```javascript
231
+
var remainder =bigDecimal.modulus('45', '4'); // remainder = '1'
232
+
```
233
+
Alternately, use the instance property. It returns the result as new `bigDecimal`.
234
+
```javascript
235
+
var n1 =newbigDecimal('45');
236
+
var n2 =newbigDecimal('4');
237
+
var remainder =n1.modulus(n2); // remainder = new bigDecimal('1')
238
+
```
239
+
Further, the result takes the sign of the dividend and the sign of the divisor is ignored. Note that this behaviour is the same as in Java and JavaScript.
0 commit comments