Difference between revisions of "Typecast"
From Free Pascal wiki
Jump to navigationJump to search (Replicate the German language page in English) |
(→Type conversion: fix heading and table data wrapping) |
||
Line 24: | Line 24: | ||
<td>Real</td> | <td>Real</td> | ||
<td>Integer</td> | <td>Integer</td> | ||
− | <td>explicit<br>Cut off the fractional<br> | + | <td>explicit<br>Cut off the fractional part.<br/> Rounds</td> |
<td><br>Trunc<br>Round</td> | <td><br>Trunc<br>Round</td> | ||
</tr> | </tr> | ||
Line 68: | Line 68: | ||
<table border ="1" cellpadding="2" cellspacing="0"> | <table border ="1" cellpadding="2" cellspacing="0"> | ||
<tr bgcolor="#C0C0C0"> | <tr bgcolor="#C0C0C0"> | ||
− | <td> | + | <td>Source data type</td> |
− | <td> | + | <td>Target data type</td> |
<td>Type of type conversion</td> | <td>Type of type conversion</td> | ||
<td>Function</td> | <td>Function</td> |
Revision as of 08:22, 11 June 2016
│
Deutsch (de) │
English (en) │
français (fr) │
русский (ru) │
Converting values from variables with a lower value range data type to variables with higher value range data type is done automatically (implicit).
A value is converted by a variable of higher-value data type into a variable with a data type of lower values via a cast, and if the value does not fit into the variable of the target data type then data will be lost.
Type conversion
Source data type | Target data type | Type of type conversion | Function |
Integer | Real | implicit | no |
Real | Integer | explicit Cut off the fractional part. Rounds |
Trunc Round |
Integer | String | explicit | IntToStr |
Real | String | explicit | FloatToStr FloatToStrF |
String | Integer | explicit | StrToInt |
String | Real | explicit | StrToFloat |
String | Char | explicit Access index |
no no |
Char | String | implicit | no |
Source data type | Target data type | Type of type conversion | Function |
QWord | Byte | explicit | Byte(QWord) |
QWord | Word | explicit | Word(QWord) |
QWord | Cardinal | explicit | Cardinal(QWord) |
QWord | Longword | explicit | Longword(QWord) |
Longword | Byte | explicit | Byte(Longword) |
Longword | Word | explicit | Word(Longword) |
Longword | Cardinal | implicit (simple value assignment) | |
Int64 | Byte | explicit | Byte(Int64) |
Int64 | Shortint | explicit | Shortint(Int64) |
Comp | Byte | explicit | Byte(Comp) |
Comp | Shortint | explicit | Shortint(Comp) |
Comp | Real | explicit | Real(Comp) |