Decimal to Hexadecimal

You must understand the Game Editor concepts, before post here.

Decimal to Hexadecimal

Postby Game A Gogo » Thu Jul 12, 2007 12:49 am

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 :\
Programming games is an art,
    Respect it.
User avatar
Game A Gogo
 
Posts: 3466
Joined: Wed Jun 29, 2005 10:49 pm
Location: French Canada *laughs*
Score: 181 Give a positive score

Re: Decimal to Hexadecimal

Postby makslane » Thu Jul 12, 2007 1:44 am

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);
makslane
Site Admin
 
Posts: 3947
Joined: Sat Apr 05, 2003 6:47 pm
Score: 182 Give a positive score

Postby Game A Gogo » Thu Jul 12, 2007 2:56 am

O,,o that easy? YOU ARE KIDDING ME :D I spent about 2 days on this, and nearly got it, thank you +1 point!!!
Programming games is an art,
    Respect it.
User avatar
Game A Gogo
 
Posts: 3466
Joined: Wed Jun 29, 2005 10:49 pm
Location: French Canada *laughs*
Score: 181 Give a positive score

Postby Game A Gogo » Thu Jul 12, 2007 3:00 am

false hope D:

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

thx a bunch!!
Programming games is an art,
    Respect it.
User avatar
Game A Gogo
 
Posts: 3466
Joined: Wed Jun 29, 2005 10:49 pm
Location: French Canada *laughs*
Score: 181 Give a positive score

Postby DocRabbit » Thu Jul 12, 2007 3:36 am

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.
Attachments
HexTesterFunction.zip
Type in a decimal number, gives you breakdown of number and hex output.
(196.29 KiB) Downloaded 180 times
User avatar
DocRabbit
 
Posts: 114
Joined: Fri Oct 27, 2006 2:56 am
Score: 10 Give a positive score

Postby kyensoftware » Thu Jul 12, 2007 11:27 am

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...
Games for Windows, Linux, and PPC
Bin dosnt stand for "Binary";
it stands for Bin.
You know, where the junk goes...
User avatar
kyensoftware
 
Posts: 198
Joined: Thu Oct 26, 2006 7:49 am
Score: 5 Give a positive score

Postby Game A Gogo » Fri Jul 13, 2007 1:05 am

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!!!
Programming games is an art,
    Respect it.
User avatar
Game A Gogo
 
Posts: 3466
Joined: Wed Jun 29, 2005 10:49 pm
Location: French Canada *laughs*
Score: 181 Give a positive score

Postby Fuzzy » Fri Jul 13, 2007 2:41 am

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) ;
}
Last edited by Fuzzy on Fri Jul 13, 2007 8:32 pm, edited 1 time in total.
Mortal Enemy of IF....THEN(and Inspector Gadget)

Still ThreeFingerPete to tekdino
User avatar
Fuzzy
 
Posts: 1068
Joined: Thu Mar 03, 2005 9:32 am
Location: Plymostic Programmer
Score: 95 Give a positive score

Postby Sgt. Sparky » Fri Jul 13, 2007 7:18 pm

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:
Image
Random Links:
viewtopic.php?p=19474#19474
Right now (10/14/2009) I'm working on some C++ projects, but I might be able to help if you have some Game Editor questions. :)
User avatar
Sgt. Sparky
 
Posts: 1850
Joined: Sat Oct 07, 2006 5:28 pm
Location: Somewhere out there, beneath the pale blue sky...
Score: 236 Give a positive score

Postby Sgt. Sparky » Fri Jul 13, 2007 7:20 pm

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
Image
Random Links:
viewtopic.php?p=19474#19474
Right now (10/14/2009) I'm working on some C++ projects, but I might be able to help if you have some Game Editor questions. :)
User avatar
Sgt. Sparky
 
Posts: 1850
Joined: Sat Oct 07, 2006 5:28 pm
Location: Somewhere out there, beneath the pale blue sky...
Score: 236 Give a positive score

Postby Game A Gogo » Sat Jul 14, 2007 1:22 am

is everyone lost?
I already made that function to reverse, and I don't need it anymore anyway!
Programming games is an art,
    Respect it.
User avatar
Game A Gogo
 
Posts: 3466
Joined: Wed Jun 29, 2005 10:49 pm
Location: French Canada *laughs*
Score: 181 Give a positive score

Postby Fuzzy » Sat Jul 14, 2007 3:17 am

I'm lost, but, NO! I like the grass!
Mortal Enemy of IF....THEN(and Inspector Gadget)

Still ThreeFingerPete to tekdino
User avatar
Fuzzy
 
Posts: 1068
Joined: Thu Mar 03, 2005 9:32 am
Location: Plymostic Programmer
Score: 95 Give a positive score

Postby Sgt. Sparky » Mon Jul 16, 2007 3:21 am

Fuzzy wrote:I'm lost, but, NO! I like the grass!

okay, :D
but I will draw better grass. :P
Image
Random Links:
viewtopic.php?p=19474#19474
Right now (10/14/2009) I'm working on some C++ projects, but I might be able to help if you have some Game Editor questions. :)
User avatar
Sgt. Sparky
 
Posts: 1850
Joined: Sat Oct 07, 2006 5:28 pm
Location: Somewhere out there, beneath the pale blue sky...
Score: 236 Give a positive score

Postby Game A Gogo » Wed Jul 18, 2007 1:14 am

why don't you make a selection to choose which grass :D
Programming games is an art,
    Respect it.
User avatar
Game A Gogo
 
Posts: 3466
Joined: Wed Jun 29, 2005 10:49 pm
Location: French Canada *laughs*
Score: 181 Give a positive score

Postby pixelpoop » Wed Jul 18, 2007 2:14 am

this guy makes good grass
http://www.jeshannon.com/Grass.htm
User avatar
pixelpoop
 
Posts: 276
Joined: Tue Aug 29, 2006 9:32 pm
Score: 28 Give a positive score

Next

Return to Advanced Topics

Who is online

Users browsing this forum: No registered users and 1 guest