ShortInt: what changed
Revision 0 to 1. Removed lines have a minus sign; added lines have a plus sign.
Title: ShortInt
| Old | New | Line | |
|---|---|---|---|
| 1 | + | A shortint is a signed integer in the range of -128 to 127. The shortint is 8 bits long. | |
| 2 | + | ||
| 3 | + | The [[Byte]] type is 8 bits long, too. But the byte datatype is an unsigned type, meaning that it encodes numbers from 0 to 255. | |
| 4 | + | ||
| 5 | + | ``` pascal | |
| 6 | + | ||
| 7 | + | var | |
| 8 | + | a_shortint: shortint; | |
| 9 | + | a_byte : byte; | |
| 10 | + | s1, s2 : string; | |
| 11 | + | begin | |
| 12 | + | a_shortint := %11110001; // binary number | |
| 13 | + | a_byte := %11110001; | |
| 14 | + | s1 := IntToStr(a_shortint); // s1 = '-15' | |
| 15 | + | s2 := IntToStr(a_byte); // s2 = '241' | |
| 16 | + | ``` | |
| 17 | + | ||
| 18 | + | ## See also | |
| 19 | + | ||
| 20 | + | - [[Not|function OnesComplement2]] | |
| 21 | + | - [[Smallint]] is integer type supporting values from -32768 to 32767 | |
| 22 | + | - [[Binary numeral system|binary numbers]] | |
| 23 | + | - [[IntToStr]] convert an integer into a string | |
| 24 | + | ||
| 25 | + | --- | |
| 26 | + | *From the Free Pascal wiki, page "ShortInt", as it stood on 2023-12-22 after a change by Alextpp, 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).* |
