Our website uses cookies to enhance your browsing experience.
Accept
to the top

Webinar: Let's make a programming language. Lexer - 29.04

>
>
>
V8015. Suspicious use of the bitwise...
menu mobile close menu
Additional information
toggle menu Contents

V8015. Suspicious use of the bitwise XOR operator '^'. The exponentiation operation may have been intended here.

Apr 03 2026

The analyzer has detected a binary expression that was potentially intended as exponentiation. The operator ^ was used for this operation, but in reality, ^ performs a bitwise exclusive "OR" operation.

The operator ^ performs exponentiation in some programming languages, such as Basic, R, and Haskell. In Go, however, ^ computes the bitwise exclusive "OR" of two operands—that is, a bitwise sum modulo 2. In Go, to raise a number to a power, use the math.Pow function. Another option is to use the left bitwise shift operator if a number is multiplied by 2 to the power of N.

The example:

x := 2 ^ 16

In this example, the expression evaluates to 18 rather than 65536, which is 2 to the power of 16. To get the power of 2, use the left bitwise shift operator.

The fixed code:

x := 1 << 16