# no-xor-as-exponentiation πŸ“ Disallow the bitwise XOR operator where exponentiation was likely intended. πŸ’Ό This rule is enabled in the following [configs](https://github.com/sindresorhus/eslint-plugin-unicorn#recommended-config): βœ… `recommended`, β˜‘οΈ `unopinionated`. πŸ’‘ This rule is manually fixable by [editor suggestions](https://eslint.org/docs/latest/use/core-concepts#rule-suggestions). In JavaScript, `^` is the [bitwise XOR](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Bitwise_XOR) operator, not exponentiation. Developers coming from languages like Lua, Julia, R, or MATLAB, or from math notation, often expect `^` to mean β€œto the power of”, so `2 ^ 32` silently evaluates to `34` instead of `4294967296`. The actual exponentiation operator is [`**`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Exponentiation). This rule flags `^` between two decimal integer literals, which is almost always this mistake. Hexadecimal, octal, and binary literals (such as `0xFF ^ 8`) and any non-literal operands (such as `flags ^ MASK`) are ignored, since those are far more likely to be intentional bitwise XOR. ## Examples ```js // ❌ const kibibyte = 2 ^ 10; // 8, not 1024 // βœ… const kibibyte = 2 ** 10; ``` ```js // ❌ const cube = 3 ^ 3; // 0, not 27 // βœ… const cube = 3 ** 3; ```