Difference between revisions of "Percent sign"

From Lazarus wiki
Jump to navigationJump to search
 
(8 intermediate revisions by 5 users not shown)
Line 1: Line 1:
<div style="float:left; margin: 0 25px 20px 0; padding:40px; font-size:500%; font-family: Georgia; background-color: #f9f9f9; border: 2px solid #777777;">%</div>
+
{{Percent sign}}
  
 +
<div style="float:right; margin: 0 25px 20px 0; padding:40px; font-size:500%; font-family: Georgia; background-color: #f9f9f9; border: 2px solid #777777;">%</div>
  
The symbol % (pronounced "percent sign") is used in [[Pascal]] in several ways:
+
In [[ASCII]], the character code decimal <syntaxhighlight lang="pascal" inline>37</syntaxhighlight> (or [[Hexadecimal|hexadecimal]] <syntaxhighlight lang="pascal" inline>25</syntaxhighlight>) is defined to be <syntaxhighlight lang="pascal" inline>%</syntaxhighlight> .
  
- its indicate [[Binary numeral system|binary numeral system]].
+
The symbol <syntaxhighlight lang="pascal" inline>%</syntaxhighlight>  (pronounced "percent sign") is used in [[Pascal]]:
 +
* it indicates a [[Binary numeral system|binary numeral expression/number]].
 +
 
 +
The percent sign also appears in Lazarus [[IDE directives]] of the form <syntaxhighlight lang="pascal" inline>{%directive}</syntaxhighlight>
 +
 
 +
 
 +
== Example ==
 +
 
 +
<syntaxhighlight lang="pascal">
 +
 
 +
program simple_binary_digit;
 +
 
 +
var b:byte;
 +
begin
 +
  b := %1010011;
 +
  writeln (b);
 +
  writeln (binStr(b,8));
 +
  writeln ;
 +
  writeln ('Press [Enter] to finish');
 +
  readln;
 +
end.
 +
 
 +
</syntaxhighlight>
 +
 
 +
The output prints as follows:
 +
 
 +
83
 +
01010011
 +
 
 +
Press [enter] to finish
 +
 
 +
{{Note|Binary number literals are not supported in [[Mode Delphi|<syntaxhighlight lang="pascal" inline>{$mode Delphi}</syntaxhighlight>]] and [[Mode TP|<syntaxhighlight lang="pascal" inline>{$mode TP}</syntaxhighlight>]].}}
 +
 
 +
== See also ==
 +
* <syntaxhighlight lang="pascal" inline>function</syntaxhighlight> [[doc:rtl/system/binstr.html|binStr]] - Convert [[Integer|integer]] to [[String|string]] with binary representation.

Latest revision as of 17:15, 6 August 2022

English (en) suomi (fi) français (fr) português (pt) русский (ru)

%

In ASCII, the character code decimal 37 (or hexadecimal 25) is defined to be % .

The symbol % (pronounced "percent sign") is used in Pascal:

The percent sign also appears in Lazarus IDE directives of the form {%directive}


Example

program simple_binary_digit;

var b:byte;
begin
  b := %1010011;
  writeln (b);
  writeln (binStr(b,8));
  writeln ;
  writeln ('Press [Enter] to finish');
  readln;
end.

The output prints as follows:

83
01010011
 
Press [enter] to finish
Light bulb  Note: Binary number literals are not supported in {$mode Delphi} and {$mode TP}.

See also