11-08-2009 18:00
Well tonight I had a bit of inspiration, and I have come up with a complete Integer To Hexadecimal function that uses No loops, No string constants, No (extra) user functions and only makes six function calls. Oh and it's faster than loop & recursion based functions.

There are two versions, one that includes the "0x" and one that doesn't.

P.S. By changing the values of the constants you can change to/from uppercase/lowercase (alternate values in comments).

https://wiki.secondlife.com/wiki/User:Strife_Onizuka/int2hex

CODE
string int2hex(integer I)
{//0x prefix version
//0xABCDEFGH
integer c = llCeil(llLog((I | 15 | (I >> 1)) & 0x7FFFFFFF) / 2.7725887222397812376689284858327) + 1;
I = I << ((9 - c) << 2);
integer A = (I >> 14) & 0x0003C000;
integer B = (I >> 16) & 0x00000F00;
integer C = (I >> 18) & 0x0000003C;
integer D = (I << 10) & 0x3C000000;
integer E = (I << 8) & 0x00F00000;
integer F = (I << 6) & 0x0003C000;
integer G = (I << 4) & 0x00000F00;
integer H = (I << 2) & 0x0000003C;

return
llGetSubString(
llInsertString(
llIntegerToBase64(
A + B + C + 0xD31D34D3//lowercase-x=0xD31D34D3, uppercase-X=0xD17D34D3
- (0x000F8000 * (A / 0x00028000))//lowercase=0x00090000, uppercase=0x000F8000
- (0x00003E00 * (B / 0x00000A00))//lowercase=0x00002400, uppercase=0x00003E00
- (0x000000F8 * (C / 0x00000028))//lowercase=0x00000090, uppercase=0x000000F8
),
5,
llIntegerToBase64(
D + E + F + G + H + 0xD34D34D3
- (0xF8000000 * (D / 0x28000000))//lowercase=0x90000000, uppercase=0xF8000000
- (0x03E00000 * (E / 0x00A00000))//lowercase=0x02400000, uppercase=0x03E00000
- (0x000F8000 * (F / 0x00028000))//lowercase=0x00090000, uppercase=0x000F8000
- (0x00003E00 * (G / 0x00000A00))//lowercase=0x00002400, uppercase=0x00003E00
- (0x000000F8 * (H / 0x00000028))//lowercase=0x00000090, uppercase=0x000000F8
)
),
0,
c
);
}

string int2hex(integer I)
{//pure hex version
//ABCDEFGH
integer A = (I >> 2) & 0x3C000000;
integer B = (I >> 4) & 0x00F00000;
integer C = (I >> 6) & 0x0003C000;
integer D = (I >> 8) & 0x00000F00;
integer E = (I << 14) & 0x3C000000;
integer F = (I << 12) & 0x00F00000;
integer G = (I << 10) & 0x0003C000;
integer H = (I << 8) & 0x00000F00;

return llGetSubString(
llInsertString(
llIntegerToBase64(
A + B + C + D + 0xD34D3400
- (0xF8000000 * (A / 0x28000000))//lowercase=0x90000000, uppercase=0xF8000000
- (0x03E00000 * (B / 0x00A00000))//lowercase=0x02400000, uppercase=0x03E00000
- (0x000F8000 * (C / 0x00028000))//lowercase=0x00090000, uppercase=0x000F8000
- (0x00003E00 * (D / 0x00000A00))//lowercase=0x00002400, uppercase=0x00003E00
),
4,
llIntegerToBase64(
E + F + G + H + 0xD34D3400
- (0xF8000000 * (E / 0x28000000))//lowercase=0x90000000, uppercase=0xF8000000
- (0x03E00000 * (F / 0x00A00000))//lowercase=0x02400000, uppercase=0x03E00000
- (0x000F8000 * (G / 0x00028000))//lowercase=0x00090000, uppercase=0x000F8000
- (0x00003E00 * (H / 0x00000A00))//lowercase=0x00002400, uppercase=0x00003E00
)
),
8 - llCeil(llLog((I | 15 | (I >> 1)) & 0x7FFFFFFF) / 2.7725887222397812376689284858327),
7
);
}


These are based on code I wrote this last march.
https://wiki.secondlife.com/wiki/User:Strife_Onizuka/int2hexdword
_____________________
Truth is a river that is always splitting up into arms that reunite. Islanded between the arms, the inhabitants argue for a lifetime as to which is the main river.
- Cyril Connolly

Without the political will to find common ground, the continual friction of tactic and counter tactic, only creates suspicion and hatred and vengeance, and perpetuates the cycle of violence.
- James Nachtwey