|
Last change
on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 13 days ago |
|
Fix frontend appearance
|
-
Property mode
set to
100644
|
|
File size:
681 bytes
|
| Line | |
|---|
| 1 | 'use strict';
|
|---|
| 2 |
|
|---|
| 3 | var $TypeError = require('es-errors/type');
|
|---|
| 4 |
|
|---|
| 5 | var ToInt32 = require('./ToInt32');
|
|---|
| 6 | var ToUint32 = require('./ToUint32');
|
|---|
| 7 |
|
|---|
| 8 | // https://262.ecma-international.org/11.0/#sec-numberbitwiseop
|
|---|
| 9 |
|
|---|
| 10 | module.exports = function NumberBitwiseOp(op, x, y) {
|
|---|
| 11 | if (op !== '&' && op !== '|' && op !== '^') {
|
|---|
| 12 | throw new $TypeError('Assertion failed: `op` must be `&`, `|`, or `^`');
|
|---|
| 13 | }
|
|---|
| 14 | if (typeof x !== 'number' || typeof y !== 'number') {
|
|---|
| 15 | throw new $TypeError('Assertion failed: `x` and `y` arguments must be Numbers');
|
|---|
| 16 | }
|
|---|
| 17 | var lnum = ToInt32(x);
|
|---|
| 18 | var rnum = ToUint32(y);
|
|---|
| 19 | if (op === '&') {
|
|---|
| 20 | return lnum & rnum;
|
|---|
| 21 | }
|
|---|
| 22 | if (op === '|') {
|
|---|
| 23 | return lnum | rnum;
|
|---|
| 24 | }
|
|---|
| 25 | return lnum ^ rnum;
|
|---|
| 26 | };
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.