web 3d图形渲染器
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

30 lines
706 B

  1. 'use strict';
  2. var GetIntrinsic = require('get-intrinsic');
  3. var $BigInt = GetIntrinsic('%BigInt%', true);
  4. var $RangeError = GetIntrinsic('%RangeError%');
  5. var $TypeError = GetIntrinsic('%TypeError%');
  6. var Type = require('../Type');
  7. var zero = $BigInt && $BigInt(0);
  8. // https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-remainder
  9. module.exports = function BigIntRemainder(n, d) {
  10. if (Type(n) !== 'BigInt' || Type(d) !== 'BigInt') {
  11. throw new $TypeError('Assertion failed: `n` and `d` arguments must be BigInts');
  12. }
  13. if (d === zero) {
  14. throw new $RangeError('Division by zero');
  15. }
  16. if (n === zero) {
  17. return zero;
  18. }
  19. // shortcut for the actual spec mechanics
  20. return n % d;
  21. };