IntegerToHex (Float function): Difference between revisions
m (1 revision) |
m (1 revision) |
||
Line 14: | Line 14: | ||
<tr><th>number</th> | <tr><th>number</th> | ||
<td>An integer value. The number must be convertible to a hex string that does not exceed the output size specified by the ''num'' value (plus a sign bit, if that is indicated). | <td>An integer value. The number must be convertible to a hex string that does not exceed the output size specified by the ''num'' value (plus a sign bit, if that is indicated). | ||
<p class="output">If ''number'' is a negative value, you must specify ''''Signed=true''''. </td></tr> | |||
</p> | |||
<tr><th>num</th> | <tr><th>num</th> | ||
<td>A non-zero numeric value that specifies the number of hex bytes to be returned. Its value must be greater than 0 and less than 5. </td></tr> | <td>A non-zero numeric value that specifies the number of hex bytes to be returned. Its value must be greater than 0 and less than 5. </td></tr> | ||
<tr><th>Signed=bool</th> | <tr><th>Signed=bool</th> | ||
<td>This name-required argument (''''Signed'''') is a boolean value that indicates whether the method object number is to be converted to signed output. If so, the resulting hex string will begin with a sign bit ''''00'''' or ''''FF''''), and a two's complement conversion is performed. | <td>This name-required argument (''''Signed'''') is a boolean value that indicates whether the method object number is to be converted to signed output. If so, the resulting hex string will begin with a sign bit ''''00'''' or ''''FF''''), and a two's complement conversion is performed. | ||
<p class="code">Signed is an optional argument that defaults to ''''False'''', which produces an unsigned conversion.</td></tr> | |||
</p> | |||
</table> | </table> | ||
==Usage notes== | ==Usage notes== | ||
Line 28: | Line 30: | ||
==Examples== | ==Examples== | ||
The following statement displays ''''00000000'''': | The following statement displays ''''00000000'''': | ||
<p class="code">[[Intrinsic classes#printtext|printText]] {0:integerToHex(4)} | |||
</p> | |||
The following statement displays ''''0000000A'''': | The following statement displays ''''0000000A'''': | ||
<p class="code">printText {10:integerToHex(4)} | |||
</p> | |||
The following statement displays ''''FF'''': | The following statement displays ''''FF'''': | ||
<p class="code">printText {255:integerToHex(1)} | |||
</p> | |||
The following statement displays ''''FF'''': | The following statement displays ''''FF'''': | ||
<p class="code">printText {-1:integerToHex(1, signed=true)} | |||
</p> | |||
==See also== | ==See also== | ||
[[List of intrinsic Float methods]] | [[List of intrinsic Float methods]] |
Revision as of 15:50, 20 January 2011
Convert an integer to a hexadecimal string (Float class)
This intrinsic function converts an integer to its hexadecimal string representation.
Only integers that convert to four hex bytes or less
(so a maximum output string length of eight) are allowed.
The IntegerToHex function is available as of version 7.5 of the Sirius Mods.
Syntax
%string = float:IntegerToHex( number, [Signed= boolean])
Syntax terms
%str | A string variable to receive the converted value of the method object number. |
---|---|
number | An integer value. The number must be convertible to a hex string that does not exceed the output size specified by the num value (plus a sign bit, if that is indicated).
If number is a negative value, you must specify 'Signed=true'. |
num | A non-zero numeric value that specifies the number of hex bytes to be returned. Its value must be greater than 0 and less than 5. |
Signed=bool | This name-required argument ('Signed') is a boolean value that indicates whether the method object number is to be converted to signed output. If so, the resulting hex string will begin with a sign bit '00' or 'FF'), and a two's complement conversion is performed.
Signed is an optional argument that defaults to 'False', which produces an unsigned conversion. |
Usage notes
- If the specified size of the returned hex value is greater than the hex value, the returned value is padded on the left with repetitions of the appropriate sign bit.
- If the specified size of the returned hex value is insufficient to contain the converted value and any necessary sign bit, the request is cancelled.
- The inverse of the IntegerToHex method is HexToInteger.
Examples
The following statement displays '00000000':
printText {0:integerToHex(4)}
The following statement displays '0000000A':
printText {10:integerToHex(4)}
The following statement displays 'FF':
printText {255:integerToHex(1)}
The following statement displays 'FF':
printText {-1:integerToHex(1, signed=true)}
See also
List of intrinsic Float methods