Difference between revisions of "Slash"

From Free Pascal wiki
Line 1: Line 1:
The '''''/''''' or '''slash''' is used in a Pascal program to perform division.  The results are a real value unless the values on both sides of the slash are integer, in which case the value is integer and the result is the same as the [[div]] operator.
+
<div style="float:right; margin: 0 0 10px 10px; padding:40px; font-size:500%; font-family: Georgia; background-color: #f9f9f9; border: 2px solid #777777;"><nowiki>/</nowiki></div>
  
 +
The '''''/''''' or '''slash''' is used in a [[Pascal]] program to perform division. The results are a real value. If you want integer type value then use the [[Div]] operator.
 +
 +
<delphi>
 
  A := 3 / 4;
 
  A := 3 / 4;
 +
</delphi>
  
returns 0.75 if a is real, and zero if a is integer.
+
returns 0.75 if a is real (if a is integer-type then get error:Incompatible types).
  
The value on the right side of the slash must not be zero, or a division by zero error occurs. This can be caught through use of a [[try]] .. [[finally]] or [[try]] .. [[except]] block.
+
The value on the right side of the slash must not be zero, or a division by zero error occurs. This can be caught through use of a [[Try|try]] .. [[Finally|finally]] or [[Try|try]] .. [[Except|except]] block.  
  
 
{{Symbols}}
 
{{Symbols}}

Revision as of 12:25, 21 October 2007

/

The / or slash is used in a Pascal program to perform division. The results are a real value. If you want integer type value then use the Div operator.

<delphi>

A := 3 / 4;

</delphi>

returns 0.75 if a is real (if a is integer-type then get error:Incompatible types).

The value on the right side of the slash must not be zero, or a division by zero error occurs. This can be caught through use of a try .. finally or try .. except block.


navigation bar: topic: Pascal symbols
single characters

+ (plus)  •  - (minus)  •  * (asterisk)  •  / (slash)
= (equal)  •  > (greater than)  •  < (less than)
. (period)  •  : (colon)  •  ; (semi colon)
^ (hat)  •  @ (at)
$ (dollar sign)  •  & (ampersand)  •  # (hash)
' (single quote)

character pairs

<> (not equal)  •  <= (less than or equal)  •  := (becomes)  •  >= (greater than or equal)

 •  >< (symmetric difference)  •  // (double slash)


An editor has declared this article to be a stub, meaning that it needs more information. Can you help out and add some? If you have some useful information, you can help the Free Pascal Wiki by clicking on the edit box on the left and expanding this page.