Hex2Int: Difference between revisions

From Second Life Wiki
Jump to navigation Jump to search
Created page with "{{LSL Header|User-Defined Functions|Void's User Page}} <!-- please do not remove added links --> <div style="float:r…"
(No difference)

Revision as of 07:21, 20 August 2013

Summary

User-Defined Function: integer Hex2Int(string hexadecimal)( string hexadecimal );

Returns a integer that is hexadecimalstring converted to integer

  • hexadecimal: source string to convert

Terse

(Leading zeros removed)

  • LSO: xxx bytes
  • MONO: xxx bytes

<lsl>// 01234567_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 ] //*/ /*//-- --//*/</lsl>

Labeled Terse

("0x" prefix, Leading zeros removed)

  • LSO: xxx bytes
  • MONO: xxx bytes

<lsl>// 0x01234567 ~ 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 ] //*/

/*//-- --//*/</lsl>

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

   llIntegerToHex() - function for integer/hex conversion