Percent sign: what changed
Revision 1 to 2. Removed lines have a minus sign; added lines have a plus sign.
| Old | New | Line | |
|---|---|---|---|
| 1 | - | ||
| 2 | - | ||
| 3 | 1 | % | |
| 4 | - | ||
| 5 | - | ||
| 6 | 2 | ||
| 7 | 3 | In [[ASCII]], the character code decimal `37` (or [[Hexadecimal|hexadecimal]] `25`) is defined to be `%` . | |
| 8 | 4 | ||
| 9 | 5 | The symbol `%` (pronounced "percent sign") is used in [[Pascal]]: | |
| 10 | 6 | ||
| 11 | 7 | - it indicates a [[Binary numeral system|binary numeral expression/number]]. | |
| 12 | 8 | ||
| 13 | 9 | The percent sign also appears in Lazarus [[IDE directives]] of the form `{%directive}` | |
| 14 | 10 | ||
| 15 | 11 | ## Example | |
| 16 | 12 | ||
| 17 | 13 | ``` pascal | |
| 18 | 14 | ||
| 19 | 15 | program simple_binary_digit; | |
| 20 | 16 | ||
| 21 | 17 | var b:byte; | |
| 22 | 18 | begin | |
| 23 | 19 | b := %1010011; | |
| 24 | 20 | writeln (b); | |
| 25 | 21 | writeln (binStr(b,8)); | |
| 26 | 22 | writeln ; | |
| 27 | 23 | writeln ('Press [Enter] to finish'); | |
| 28 | 24 | readln; | |
| 29 | 25 | end. | |
| 30 | 26 | ``` | |
| 31 | 27 | ||
| 32 | 28 | The output prints as follows: | |
| 33 | 29 | ||
| 34 | 30 | `83`\ | |
| 35 | 31 | `01010011`\ | |
| 36 | 32 | ` `\ | |
| 37 | 33 | `Press [enter] to finish` | |
| 38 | 34 | ||
| 39 | 35 | > **Note:** Binary number literals are not supported in [[Mode Delphi|{$mode Delphi}]] and [[Mode TP|{$mode TP}]]. | |
| 40 | 36 | ||
| 41 | 37 | ## See also | |
| 42 | 38 | ||
| 43 | 39 | - `function` [[doc:rtl/system/binstr.html|binStr]] - Convert [[Integer|integer]] to [[String|string]] with binary representation. | |
| 44 | 40 | ||
| 45 | 41 | --- | |
| 46 | 42 | *From the Free Pascal wiki, page "Percent sign", 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).* |
