microsoft/qdk

Public

mirrored from https://github.com/microsoft/qdkAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
v1.3.0

Branches

Tags

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

Clone

HTTPS

Download ZIP

samples/language/ComparisonOperators.qs

76lines · modeblame

1d8e82fcScott Carda2 years ago1/// # 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()
11operation Main() : Unit {
12
13// `==` tests if the first value is equivalent to the second value.
14
15// The Boolean value `true`.
16let boolean = 4 == 4;
17
18// The Boolean value `false`.
19let 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`.
25let boolean = 4 != 4;
26
27// The Boolean value `true`.
28let boolean = 4 != 6;
29
30// `<` tests if the first value is strictly less than the second value.
31
32// The Boolean value `false`.
33let boolean = 4 < 4;
34
35// The Boolean value `true`.
36let boolean = 4 < 6;
37
38// The Boolean value `false`.
39let 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`.
45let boolean = 4 <= 4;
46
47// The Boolean value `true`.
48let boolean = 4 <= 6;
49
50// The Boolean value `false`.
51let boolean = 6 <= 4;
52
53// `>` tests if the first value is strictly greater than the second value.
54
55// The Boolean value `false`.
56let boolean = 4 > 4;
57
58// The Boolean value `false`.
59let boolean = 4 > 6;
60
61// The Boolean value `true`.
62let 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`.
68let boolean = 4 >= 4;
69
70// The Boolean value `false`.
71let boolean = 4 >= 6;
72
73// The Boolean value `true`.
74let boolean = 6 >= 4;
75}
76}