main
Last change
on this file was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago |
Update repo after prototype presentation
|
-
Property mode
set to
100644
|
File size:
672 bytes
|
Line | |
---|
1 | 'use strict';
|
---|
2 |
|
---|
3 | var GetIntrinsic = require('get-intrinsic');
|
---|
4 |
|
---|
5 | var $BigInt = GetIntrinsic('%BigInt%', true);
|
---|
6 | var $RangeError = require('es-errors/range');
|
---|
7 | var $TypeError = require('es-errors/type');
|
---|
8 |
|
---|
9 | var zero = $BigInt && $BigInt(0);
|
---|
10 |
|
---|
11 | // https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-remainder
|
---|
12 |
|
---|
13 | module.exports = function BigIntRemainder(n, d) {
|
---|
14 | if (typeof n !== 'bigint' || typeof d !== 'bigint') {
|
---|
15 | throw new $TypeError('Assertion failed: `n` and `d` arguments must be BigInts');
|
---|
16 | }
|
---|
17 |
|
---|
18 | if (d === zero) {
|
---|
19 | throw new $RangeError('Division by zero');
|
---|
20 | }
|
---|
21 |
|
---|
22 | if (n === zero) {
|
---|
23 | return zero;
|
---|
24 | }
|
---|
25 |
|
---|
26 | // shortcut for the actual spec mechanics
|
---|
27 | return n % d;
|
---|
28 | };
|
---|
Note:
See
TracBrowser
for help on using the repository browser.