Integer: The range is -32768~32767, so its element number is 32767-(-32768). For each element, such as 1, its predecessor (the previous element) is 0, and its successor (the latter element) is 2, which cannot be any other number. Just say integer.
Similarly, longint is the same.
But real numbers, single precision and double precision are not ordered types. For example, can you tell me how many elements a real number has? Obviously it is theoretically infinite (regardless of accuracy). Can you tell me exactly what the next element of 1 is? 1. 1? 1.0 1? 1.00 1? 1.000 1? 1.0.......0 1? ..... Obviously, no one can be said to be its next element, because you can always say that the number of an element is smaller than those mentioned just now and greater than 1, so we define it as disorder.
In fact, there is a very simple way to test whether a type is ordered, that is, through the for loop test, all types that can be used as the upper and lower bounds of the for loop are ordered, and others are not, but there are exceptions. for example, int64 is also an ordered type, but the for loop cannot be used.
Explanation:
For example, an integer
defined variable
I: integer;
begin
For i:= 1 to maxint- 1 do.
End.
Compiled, so integers are appropriate.
defined variable
c:char;
begin
For c:='a' to' z' do
End.
Compilation also passed, so char is also orderly.
When the type of I is changed to real, double, string and ansistring, you will find a compilation error, because they are not in order, so you can't judge what the next element is and you can't loop.
The ordered types may be these:
Integer longint shortcut word qword byte int 64 char enumeration type
The rest are generally messy, and I can't say it all at the moment. If you want to ask anything, you can come to me ...