Sign in Join
Wiki copytemporary

Greater than: what changed

Revision 1 to 2. Removed lines have a minus sign; added lines have a plus sign.

OldNewLine
1-<div style="float:right; margin: 0 20px 10px 0; padding:40px; font-size:500%; font-family: Georgia; background-color: #f9f9f9; border: 2px solid #777777;">
2-
31\>
4-
5-</div>
62
73In [[ASCII]], the character code decimal `62` (or [[Hexadecimal|hexadecimal]] `3E`) is defined to be `>` (greater-than sign).
84
95## comparison operator
106
117### true greater than
128
139The greater than symbol `>` is used to compare whether the value on the left side of the symbol, exceeds that of the value to the right side of the symbol. The [[expression]] results in a [[Boolean|boolean value]].
1410
1511``` pascal
1612program comparisonDemo(input, output, stderr);
1713
1814type
1915 size = (tiny, small, medium, large, huge);
2016
2117var
2218 n, m: longint;
2319 c, d: char;
2420
2521begin
2622 // of course, integers can be compared
2723 n := 2;
2824 m := -2;
2925
3026 if n > m then
3127 begin
3228 writeLn(n, ' > ', m);
3329 end;
3430
3531 // also enumerative types can be ordered
3632 if huge > medium then
3733 begin
3834 writeLn('huge is greater than medium');
3935 end;
4036
4137 // but the constants true and false are also comparable
4238 if true > false then
4339 begin
4440 writeLn('true is greater than false');
4541 end;
4642
4743 // characters stay in a relation to each other, too
4844 // (result depends on the used character set)
4945 c := 'a';
5046 d := 'Z';
5147
5248 if c > d then
5349 begin
5450 writeLn(c, ' > ', d);
5551 end;
5652end.
5753```
5854
5955All ordinal types can be compared to values of the same type. Integers can be compared to any integer.
6056
6157``` pascal
6258program comparisonSignedDemo(input, output, stderr);
6359
6460var
6561 n: int64;
6662 m: qword;
6763
6864begin
6965 n := -1; // n stored as %111...111
7066 m := 2; // m stored as %000...010
7167
7268 // signed comparison
7369 if n > m then
7470 begin
7571 writeLn(n, ' > ', m);
7672 end;
7773
7874 // "unsigned" comparison
7975 if qword(n) > m then
8076 begin
8177 writeLn('qword(', n, ') > ', m);
8278 end;
8379end.
8480```
8581
8682### greater than or equal to
8783
8884If the greater than symbol is followed by an [[Equal|equal sign]] `>=`, the comparison also results in [[True|true]] if both operands are equal to each other.
8985
9086## bit shift operator
9187
9288Two consecutive greater-than signs `>>` act as the [[Shr|shr operator]].
9389
9490## template list
9591
9692In [[Generics|generic type]] definitions the template list is delimited by a closing `>`.
9793
9894---
9995*From the Free Pascal wiki, page "Greater than", as it stood on 2022-08-06 after a change by Kai Burghardt, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).*

Back to history