DocumentDB LogoDocumentDB
HomeGitHubDiscordDocsBlogs
Back to DocumentationMQL Documentation
CommandsAggregationQuery And Write
OperatorsAccumulatorAggregationArithmetic ExpressionArray ExpressionArray QueryArray UpdateBitwiseBitwise QueryBitwise UpdateBoolean ExpressionComparison QueryConditional ExpressionData SizeDate ExpressionElement QueryEvaluation QueryField UpdateGeospatialLogical QueryMiscellaneousObject ExpressionProjectionSet ExpressionTimestamp ExpressionVariable ExpressionWindow
Reference/Operators/Bitwise

MongoDB Query Language (MQL) Bitwise Operators

$bitAnd

The `$bitAnd` operator performs a bitwise AND operation on integer values. It compares each bit of the first operand to the corresponding bit of the second operand. If both bits are 1, the corresponding result bit is set to 1. Otherwise, the corresponding result bit is set to 0.

$bitNot

The `$bitNot` operator performs a bitwise NOT operation on integer values. It inverts all the bits of the operand, turning 1s into 0s and 0s into 1s. The result is the bitwise complement of the input value.

$bitOr

The `$bitOr` operator performs a bitwise OR operation on integer values. It compares each bit of the first operand to the corresponding bit of the second operand. If either bit is 1, the corresponding result bit is set to 1. If both bits are 0, the corresponding result bit is set to 0.

$bitXor

The `$bitXor` operator performs a bitwise exclusive OR (XOR) operation on integer values. The XOR operation returns 1 for each bit position where the corresponding bits of the operands are different, and 0 where they are the same.

Copyright © DocumentDB a Series of LF Projects, LLC. For web site terms of use, trademark policy and other project policies please see https://lfprojects.org.