Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


How do I convert byte to 4 bytes?

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General Gamehacking
View previous topic :: View next topic  
Author Message
Lemonlime
Expert Cheater
Reputation: 0

Joined: 15 Sep 2007
Posts: 139

PostPosted: Tue Jan 12, 2010 11:12 am    Post subject: How do I convert byte to 4 bytes? Reply with quote

Hey guys.

I tried google it but with no luck.

I need to convert a byte value into 4 bytes, how do I calculate this?
A friend told me that 206 (byte) is 02030030 (4 bytes).
Back to top
View user's profile Send private message
Psy
Grandmaster Cheater Supreme
Reputation: 1

Joined: 27 Mar 2008
Posts: 1366

PostPosted: Tue Jan 12, 2010 12:07 pm    Post subject: Reply with quote

206 is a decimal number, not hexadecimal. A hex 'byte' has a range of between: 0x00 -> 0xFF.

206 == 0xCE as a byte. This is displayed as 0x000000CE in 4-byte notation (DWORD).

Another example:
9999 == 0x270F which is greater than a byte. It requires 2-bytes of storage space (WORD). Displayed as 4-byte is: 0x0000270F.

You get the idea. How in the world can a byte value by some completely different number? I think you seriously need to find new sources of info man. That's the third post at least where the info couldn't be more false.
Back to top
View user's profile Send private message
Lemonlime
Expert Cheater
Reputation: 0

Joined: 15 Sep 2007
Posts: 139

PostPosted: Tue Jan 12, 2010 12:45 pm    Post subject: Reply with quote

Oh lol, I don't think I made myself clear enough.

And this info is me who missunderstood something. Don't worry about it, I figured it out Very Happy
Back to top
View user's profile Send private message
rooski
Master Cheater
Reputation: 0

Joined: 31 Oct 2007
Posts: 340
Location: Siberia

PostPosted: Wed Jan 27, 2010 3:11 pm    Post subject: Reply with quote

IM trying to do the opposite of this (converting 4BYTE to BYTE) how would i go about doing that?
Back to top
View user's profile Send private message
Psy
Grandmaster Cheater Supreme
Reputation: 1

Joined: 27 Mar 2008
Posts: 1366

PostPosted: Thu Jan 28, 2010 3:45 am    Post subject: Reply with quote

Well if the value is greater than 255 (unsigned) you have a problem, as a BYTE (unsigned) value has a range of 0-255. So if you're 4-byte value is anything greater, such as 1,000,000, then you are going to lose data in the transfer. There's a reason that different datatypes are used for different purposes.Can I ask why you are wanting to do this? I get the sense that here is probably a better way of doing what you are needing Smile
Back to top
View user's profile Send private message
rooski
Master Cheater
Reputation: 0

Joined: 31 Oct 2007
Posts: 340
Location: Siberia

PostPosted: Thu Jan 28, 2010 1:15 pm    Post subject: Reply with quote

im trying to make a bot to play old snes games Wink , so i need to read the values , and most are byte . thinking of doing some GA's for it also , anyway DarkByte put this on a previous thread.


Dark Byte wrote:
you could also use "unsigned char mybuffer;"
that way "ReadProcessMemory(hProcess, ULongToPtr(Address), &MyBuffer, sizeof(MyBuffer), NULL); " will only read the 1 byte at the specified address

as for converting a 4 byte to a byte:
Code:

BYTE mybyte;
DWORD my4bytevalue;

my4bytevalue=112;
mybyte=my4bytevalue;



now if my4bytevalue is bigger than 255 then the higher bits will be lost
Back to top
View user's profile Send private message
Psy
Grandmaster Cheater Supreme
Reputation: 1

Joined: 27 Mar 2008
Posts: 1366

PostPosted: Thu Jan 28, 2010 2:46 pm    Post subject: Reply with quote

Yeah if the values are already BYTE, then just read them into a BYTE and not DWORD. Then you save the hassle of converting. That would be the logical way yup.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General Gamehacking All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites