IntegerToHex (Float function): Difference between revisions
Jump to navigation
Jump to search
mNo edit summary |
mNo edit summary |
||
Line 39: | Line 39: | ||
===See also=== | ===See also=== | ||
[[List of | [[List of intrinsic Float methods]] | ||
[[Category: Intrinsic Float methods|IntegerToHex function]] | [[Category: Intrinsic Float methods|IntegerToHex function]] | ||
[[Category: Intrinsic methods]] | [[Category: Intrinsic methods]] |
Revision as of 15:57, 29 December 2010
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.
IntegerToHex syntax
%str = number:IntegerToHex(num, [Signed=bool])
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