View previous topic :: View next topic |
Author |
Message |
Lemonlime Expert Cheater Reputation: 0
Joined: 15 Sep 2007 Posts: 139
|
Posted: Tue Jan 12, 2010 11:12 am Post subject: How do I convert byte to 4 bytes? |
|
|
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 |
|
|
Psy Grandmaster Cheater Supreme Reputation: 1
Joined: 27 Mar 2008 Posts: 1366
|
Posted: Tue Jan 12, 2010 12:07 pm Post subject: |
|
|
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 |
|
|
Lemonlime Expert Cheater Reputation: 0
Joined: 15 Sep 2007 Posts: 139
|
Posted: Tue Jan 12, 2010 12:45 pm Post subject: |
|
|
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
|
|
Back to top |
|
|
rooski Master Cheater Reputation: 0
Joined: 31 Oct 2007 Posts: 340 Location: Siberia
|
Posted: Wed Jan 27, 2010 3:11 pm Post subject: |
|
|
IM trying to do the opposite of this (converting 4BYTE to BYTE) how would i go about doing that?
|
|
Back to top |
|
|
Psy Grandmaster Cheater Supreme Reputation: 1
Joined: 27 Mar 2008 Posts: 1366
|
Posted: Thu Jan 28, 2010 3:45 am Post subject: |
|
|
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
|
|
Back to top |
|
|
rooski Master Cheater Reputation: 0
Joined: 31 Oct 2007 Posts: 340 Location: Siberia
|
Posted: Thu Jan 28, 2010 1:15 pm Post subject: |
|
|
im trying to make a bot to play old snes games , 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 |
|
|
Psy Grandmaster Cheater Supreme Reputation: 1
Joined: 27 Mar 2008 Posts: 1366
|
Posted: Thu Jan 28, 2010 2:46 pm Post subject: |
|
|
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 |
|
|
|