IntegerToHex (Float function): Difference between revisions
Jump to navigation
Jump to search
mNo edit summary |
mNo edit summary |
||
Line 1: | Line 1: | ||
{{Template:Float:IntegerToHex subtitle}} | |||
This [[Intrinsic classes|intrinsic]] function converts an integer to its hexadecimal string representation. | This [[Intrinsic classes|intrinsic]] function converts an integer to its hexadecimal string representation. | ||
Only integers that convert to four hex bytes or less | Only integers that convert to four hex bytes or less | ||
Line 4: | Line 6: | ||
The IntegerToHex function is available as of version 7.5 of the [[Sirius Mods]]. | The IntegerToHex function is available as of version 7.5 of the [[Sirius Mods]]. | ||
== | ==Syntax== | ||
{{Template:Float:IntegerToHex syntax}} | |||
===Syntax terms=== | |||
<dl> | <dl> | ||
<dt>%str | <dt>%str | ||
Line 23: | Line 25: | ||
Signed is an optional argument that defaults to ''''False'''', which produces an unsigned conversion. | Signed is an optional argument that defaults to ''''False'''', which produces an unsigned conversion. | ||
</dl> | </dl> | ||
==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 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. | *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 (String function)|HexToInteger]]. | *The inverse of the IntegerToHex method is [[HexToInteger (String function)|HexToInteger]]. | ||
==Examples== | |||
The following statement displays ''''00000000'''': | The following statement displays ''''00000000'''': | ||
[[Intrinsic classes#printtext|printText]] {0:integerToHex(4)} | [[Intrinsic classes#printtext|printText]] {0:integerToHex(4)} |
Revision as of 13:42, 19 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