Files
cppdraft_translate/cppdraft/expr/xor.md
2025-10-25 03:02:53 +03:00

33 lines
1.4 KiB
Markdown
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

[expr.xor]
# 7 Expressions [[expr]](./#expr)
## 7.6 Compound expressions [[expr.compound]](expr.compound#expr.xor)
### 7.6.12 Bitwise exclusive OR operator [expr.xor]
[exclusive-or-expression:](#nt:exclusive-or-expression "7.6.12Bitwise exclusive OR operator[expr.xor]")
[*and-expression*](expr.bit.and#nt:and-expression "7.6.11Bitwise AND operator[expr.bit.and]")
[*exclusive-or-expression*](#nt:exclusive-or-expression "7.6.12Bitwise exclusive OR operator[expr.xor]") ^ [*and-expression*](expr.bit.and#nt:and-expression "7.6.11Bitwise AND operator[expr.bit.and]")
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/expressions.tex#L7693)
The ^ operator groups left-to-right[.](#1.sentence-1)
The operands shall be of integral or unscoped enumeration type[.](#1.sentence-2)
The usual arithmetic conversions ([[expr.arith.conv]](expr.arith.conv "7.4Usual arithmetic conversions")) are performed[.](#1.sentence-3)
Given the coefficients xi and yi of the base-2 representation ([[basic.fundamental]](basic.fundamental "6.9.2Fundamental types"))
of the converted operands x and y,
the coefficient ri of the base-2 representation of the result r is 1 if either (but not both) of xi and yi is 1,
and 0 otherwise[.](#1.sentence-4)
[*Note [1](#note-1)*:
The result is the bitwise exclusive or function of the operands[.](#1.sentence-5)
— *end note*]