// A method for obtaining the maximum value of an unsigned integer: Procedure tform1.button1click (Sender: tobject); var {there are only three unsigned integer types in Delphi standard} num_byte: byte; num_word: word; num_cardinal: Cardinal; {There are too many corresponding types in Windows APIs. Below are a few} api_uchar: uchar; {byte} api_langid: langid; {word} api_dword: DWORD; {Cardinal} api_longword: longword; {Cardinal} api_uint: uint; {Cardinal} api_thandle: thandle; {Cardinal} api_hwnd: hwnd; {Cardinal} begin num_byte: = byte (-1); showmessage (inttostr (num_byte); {255} num_word: = word (-1); showmessage (inttostr (num_word); {65535} num_cardinal: = Cardinal (-1); showmessage (inttostr (num_cardinal); {4294967295} api_uchar: = uchar (-1); showmessage (inttostr (api_uchar); {255} api_langid: = langid (-1); showmessage (inttostr (api_langid); {65535} api_dword: = DWORD (-1); showmessage (inttostr (api_dword); {4294967295} api_longword: = longword (-1); showmessage (inttostr (api_longword); {4294967295} api_uint: = uint (-1); showmessage (inttostr (api_uint); {4294967295} api_thandle: = thandle (-1); showmessage (inttostr (api_thandle); {4294967295} api_hwnd: = hwnd (-1); showmessage (inttostr (api_hwnd); {4294967295} end;
<xmp> &lt;Br/&gt; simple analysis: &lt;/P&gt; &lt;p&gt; for example, if word is two-byte 16-bit, &lt;br/&gt; the maximum value is 11111111 11111111 in binary format; &lt;/P&gt; &lt;p&gt; if it can represent-1, the &lt;SPAN class = &#39;wp _ keywordlink &#39;&gt; algorithm &lt;/span&gt; of the negative number is: anticode + 1: &lt;br/&gt; the binary value of 1 is 00000000 00000001. &lt;br/&gt; the backend Code of 1 is 11111111 11111110. &lt;br/&gt; after completing 1, it is: 11111111 11111111 &lt;/P&gt; &lt;p&gt; word has no negative number. Of course, 11111111 11111111 is its maximum value. &lt;br/&gt; </xmp>