microsoft/qdk

Public

mirrored fromhttps://github.com/microsoft/qdkAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
billti/wgpu

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

samples/language/ComparisonOperators.qs

76lines · modecode

1/// # Sample
2/// Comparison Operators
3///
4/// # Description
5/// Comparison operators in Q# are used to compare one value relative to
6/// another value of the same type, producing an output Boolean value.
7/// The comparison operators in Q# are `==`, `!=`, `<`, `<=`, `>`, and `>=`.
8namespace MyQuantumApp {
9
10 @EntryPoint()
11 operation Main() : Unit {
12
13 // `==` tests if the first value is equivalent to the second value.
14
15 // The Boolean value `true`.
16 let boolean = 4 == 4;
17
18 // The Boolean value `false`.
19 let boolean = 4 == 6;
20
21 // `!=` tests if the first value is not equivalent to the second value.
22 // It is the opposite of `==`.
23
24 // The Boolean value `false`.
25 let boolean = 4 != 4;
26
27 // The Boolean value `true`.
28 let boolean = 4 != 6;
29
30 // `<` tests if the first value is strictly less than the second value.
31
32 // The Boolean value `false`.
33 let boolean = 4 < 4;
34
35 // The Boolean value `true`.
36 let boolean = 4 < 6;
37
38 // The Boolean value `false`.
39 let boolean = 6 < 4;
40
41 // `<=` tests if the first value is less than or equivalent to
42 // the second value.
43
44 // The Boolean value `true`.
45 let boolean = 4 <= 4;
46
47 // The Boolean value `true`.
48 let boolean = 4 <= 6;
49
50 // The Boolean value `false`.
51 let boolean = 6 <= 4;
52
53 // `>` tests if the first value is strictly greater than the second value.
54
55 // The Boolean value `false`.
56 let boolean = 4 > 4;
57
58 // The Boolean value `false`.
59 let boolean = 4 > 6;
60
61 // The Boolean value `true`.
62 let boolean = 6 > 4;
63
64 // `>=` tests if the first value is greater than or equivalent to
65 // the second value.
66
67 // The Boolean value `true`.
68 let boolean = 4 >= 4;
69
70 // The Boolean value `false`.
71 let boolean = 4 >= 6;
72
73 // The Boolean value `true`.
74 let boolean = 6 >= 4;
75 }
76}
77