Re: Convert int to char array (easy but...)
- From: clinisbut <clinisbut@xxxxxxxxx>
- Date: Fri, 30 Nov 2007 10:15:10 -0800 (PST)
On 30 nov, 14:47, Thomas Fritsch <i.dont.like.s...@xxxxxxxxxxx> wrote:
clinisbut wrote:
What I want to do exactly is this:
I need to split (in a binary way) an Int into two bytes.
Something like:
int value : 340
same value in binary: 101010100
convert this to 2 bytes:
byte1 = 2 ( 1 in binary );
byte1 = 1 ( 1 in binary );
byte2 = 84 ( 1010100 );
I'm trying to do this but does not work:
byte1 = value>>8;
byte2 = value & 0x00FF;
But gives me wrong values... What I'm doing wrong!?
You calculated wrong byte1. See above.
I get byte1=1 and byte2=84.
--
Thomas
Sorry, obviously I misstyped 1...
.
- References:
- Convert int to char array (easy but...)
- From: clinisbut
- Re: Convert int to char array (easy but...)
- From: Thomas Fritsch
- Convert int to char array (easy but...)
- Prev by Date: Re: Tiles w/o Stuts problem.
- Next by Date: Re: Tiles w/o Stuts problem.
- Previous by thread: Re: Convert int to char array (easy but...)
- Next by thread: Re: Convert int to char array (easy but...)
- Index(es):