Page 1 of 2

Decimal to Hexadecimal

PostPosted: Thu Jul 12, 2007 12:49 am
by Game A Gogo
Yeah, this one will probably go unanswered.

But I need to transform a number like 16191 to hexadecimal 3F3F.
But since GE does not support hexadecimal, I tough I could store each byte into an array of 4 char, so it would come out as:

Code: Select all
[0] [1] [2] [3]
00  00  63  63


so, its basically to convert 16191 to 00|00|63|63
anyone can tell me how to do this?

Fuzzy tried to help me, but I have no idea what and how to do what he told me to :\

Re: Decimal to Hexadecimal

PostPosted: Thu Jul 12, 2007 1:44 am
by makslane
Game A Gogo wrote:GE does not support hexadecimal


???

You can use:

Code: Select all
sprintf(text, "%X", 16191);


or

Code: Select all
sprintf(text, "%X", your_integer_var);

PostPosted: Thu Jul 12, 2007 2:56 am
by Game A Gogo
O,,o that easy? YOU ARE KIDDING ME :D I spent about 2 days on this, and nearly got it, thank you +1 point!!!

PostPosted: Thu Jul 12, 2007 3:00 am
by Game A Gogo
false hope D:

I want them to be stored into char, but I guess I can work whit around whit that!

thx a bunch!!

PostPosted: Thu Jul 12, 2007 3:36 am
by DocRabbit
Well, after reading Makslane's post, boy do I feel bad. :oops: Anyway, if you want to take a look at this, I went the long way around to do this, but it works.

PostPosted: Thu Jul 12, 2007 11:27 am
by kyensoftware
Hahahaha...someone needs to take over and make makslane a free version of GE!!! lol!
EDIT: I forgot, i made a script to do this, using that sprintf function, but it would always add FF to the front and end...

PostPosted: Fri Jul 13, 2007 1:05 am
by Game A Gogo
haha, anyway, I do not need this anymore, Fuzzy told me I could simply use RIFX instead of RIFF in the wave header... xD

thank you for your effort, much appreciated!!!

PostPosted: Fri Jul 13, 2007 2:41 am
by Fuzzy
Some endian inversion functions I found and converted to C.
Code: Select all
int function Reverse (int n)
{
unsigned char B0;
unsigned char B1;
unsigned char B2;
unsigned char B3;
    B0 = N % 256 ;
    N  = N / 256 ;
    B1 = N % 256 ;
    N  = N / 256 ;
    B2 = N % 256 ;
    N  = N / 256 ;
    B3 = N % 256 ;
    return (((B0 * 256 + B1) * 256 + B2) * 256 + B3) ;
}

int Reverse (int n)
{
unsigned char B0;
unsigned char B1;
unsigned char B2;
unsigned char B3;
    B0 = (N & $000000FF) >>  0 ;
    B1 = (N & $0000FF00) >>  8 ;
    B2 = (N & $00FF0000) >> 16 ;
    B3 = (N & $FF000000) >> 24 ;
    return (B0 << 24) | (B1 << 16) | (B2 << 8) | (B3 << 0) ;
}

PostPosted: Fri Jul 13, 2007 7:18 pm
by Sgt. Sparky
I think you should of put that in a
Code: Select all
[code][/code]

because of that little smiley created with the
Code: Select all
8)

:D
but I did not know GE did support hexadecimal either.
:lol:

PostPosted: Fri Jul 13, 2007 7:20 pm
by Sgt. Sparky
Game A Gogo wrote:false hope D:

I want them to be stored into char, but I guess I can work whit around whit that!

thx a bunch!!

all you have to do is store it onto a string then use my function to orgonize it. :D

PostPosted: Sat Jul 14, 2007 1:22 am
by Game A Gogo
is everyone lost?
I already made that function to reverse, and I don't need it anymore anyway!

PostPosted: Sat Jul 14, 2007 3:17 am
by Fuzzy
I'm lost, but, NO! I like the grass!

PostPosted: Mon Jul 16, 2007 3:21 am
by Sgt. Sparky
Fuzzy wrote:I'm lost, but, NO! I like the grass!

okay, :D
but I will draw better grass. :P

PostPosted: Wed Jul 18, 2007 1:14 am
by Game A Gogo
why don't you make a selection to choose which grass :D

PostPosted: Wed Jul 18, 2007 2:14 am
by pixelpoop
this guy makes good grass
http://www.jeshannon.com/Grass.htm