-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathBitwise.qs
More file actions
19 lines (17 loc) · 897 Bytes
/
Copy pathBitwise.qs
File metadata and controls
19 lines (17 loc) · 897 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
namespace ExpressionsExamples {
open Microsoft.Quantum.Intrinsic;
/// # Summary
/// The collection of examples of bitwise expressions.
operation BitwiseExamples() : Unit {
Message("============================== Q# expressions: bitwise expressions ==============================");
// Bitwise expressions are defined for Int and BigInt types.
let a = 42; // 42 = 0b101010
let b = 13; // 13 = 0b001101
Message($"A and B = {a &&& b}"); // 8 = 0b001000
Message($"A or B = {a ||| b}"); // 47 = 0b101111
Message($"A xor B = {a ^^^ b}"); // 39 = 0b100111
Message($"not A = {~~~a}"); // -43
Message($"A >>> 2 = {a >>> 2}"); // 10 = 0b001010
Message($"A <<< 1 = {a <<< 1}"); // 84 = 0b1010100
}
}