Difference between revisions of "Hex2Int"
Jump to navigation
Jump to search
m ((string hexadecimal)) |
m (<lsl> tag to <source>) |
||
(One intermediate revision by one other user not shown) | |||
Line 4: | Line 4: | ||
|title=<div style="display:none"><h2>Summary</h2></div>[[:Category:LSL_User-Defined_Functions|User-Defined Function]]: [[integer]] Hex2Int( [[string]] ''hexadecimal'' ); | |title=<div style="display:none"><h2>Summary</h2></div>[[:Category:LSL_User-Defined_Functions|User-Defined Function]]: [[integer]] Hex2Int( [[string]] ''hexadecimal'' ); | ||
|content= | |content= | ||
Returns a [[integer]] that is ''hexadecimal''[[string]] converted to [[integer]] | Returns a [[integer]] that is ''hexadecimal'' [[string]] converted to [[integer]] | ||
* ''hexadecimal'': source string to convert | * ''hexadecimal'': source string to convert | ||
Line 12: | Line 12: | ||
* MONO: xxx bytes | * MONO: xxx bytes | ||
<!-- Please replace with similarly licensed code only --> | <!-- Please replace with similarly licensed code only --> | ||
< | <source lang="lsl2">// "012afc67" hex ~ 32 bit | ||
integer simpleHex2Int(string hexadecimal) | integer simpleHex2Int(string hexadecimal) | ||
return (integer)( "0x" + llGetSubString(hexadecimal, 0, 7) ); | return (integer)( "0x" + llGetSubString(hexadecimal, 0, 7) ); | ||
Line 20: | Line 20: | ||
/*// 2013 (CC0) [ http://creativecommons.org/publicdomain/zero/1.0 ] //*/ | /*// 2013 (CC0) [ http://creativecommons.org/publicdomain/zero/1.0 ] //*/ | ||
/*// Fashion Atlas [ https://wiki.secondlife.com/wiki/User:Fashion_Atlas ] //*/ | /*// Fashion Atlas [ https://wiki.secondlife.com/wiki/User:Fashion_Atlas ] //*/ | ||
/*//-- --//*/</ | /*//-- --//*/</source> | ||
<h3>Labeled Terse</h3> | <h3>Labeled Terse</h3> | ||
Line 27: | Line 27: | ||
* MONO: xxx bytes | * MONO: xxx bytes | ||
<!-- Please replace with similarly licensed code only --> | <!-- Please replace with similarly licensed code only --> | ||
< | <source lang="lsl2">// "0x012afc67" ~ 32 bit | ||
integer Hex2Int(string hexadecimal) | integer Hex2Int(string hexadecimal) | ||
return (integer)hexadecimal; | return (integer)hexadecimal; | ||
Line 35: | Line 35: | ||
/*// 2013 (CC0) [ http://creativecommons.org/publicdomain/zero/1.0 ] //*/ | /*// 2013 (CC0) [ http://creativecommons.org/publicdomain/zero/1.0 ] //*/ | ||
/*// Fashion Atlas [ https://wiki.secondlife.com/wiki/User:Fashion_Atlas ] //*/ | /*// Fashion Atlas [ https://wiki.secondlife.com/wiki/User:Fashion_Atlas ] //*/ | ||
/*//-- --//*/</ | /*//-- --//*/</source> | ||
}} | }} |
Latest revision as of 14:15, 22 January 2015
LSL Portal | Functions | Events | Types | Operators | Constants | Flow Control | Script Library | Categorized Library | Tutorials | User-Defined Functions | Void's User Page |
User-Defined Function: integer Hex2Int( string hexadecimal );
Returns a integer that is hexadecimal string converted to integer
- hexadecimal: source string to convert
Terse
(Leading zeros removed)
- LSO: xxx bytes
- MONO: xxx bytes
// "012afc67" hex ~ 32 bit
integer simpleHex2Int(string hexadecimal)
return (integer)( "0x" + llGetSubString(hexadecimal, 0, 7) );
/*//-- Anti-License Text --//*/
/*// Contributed Freely to the Public Domain without limitation. //*/
/*// 2013 (CC0) [ http://creativecommons.org/publicdomain/zero/1.0 ] //*/
/*// Fashion Atlas [ https://wiki.secondlife.com/wiki/User:Fashion_Atlas ] //*/
/*//-- --//*/
Labeled Terse
("0x" prefix, Leading zeros removed)
- LSO: xxx bytes
- MONO: xxx bytes
// "0x012afc67" ~ 32 bit
integer Hex2Int(string hexadecimal)
return (integer)hexadecimal;
/*//-- Anti-License Text --//*/
/*// Contributed Freely to the Public Domain without limitation. //*/
/*// 2013 (CC0) [ http://creativecommons.org/publicdomain/zero/1.0 ] //*/
/*// Fashion Atlas [ https://wiki.secondlife.com/wiki/User:Fashion_Atlas ] //*/
/*//-- --//*/
Notes
- All Labeled formats can be cast directly to integer within LSL
- Full formats are optimal for fixed width viewing, or packing into raw strings.
- Portable formats are designed for compatibility with outside systems that may use different bit lengths
- Suggest using the smallest compiled version that fits your needs
See Also
- User:Strife_Onizuka/int2hex - Another Integer->Hex function but without using a loop.
![]() |
![]() |
SVC-6660 | A | llIntegerToHex() - function for integer/hex conversion |