M
Muddy Coder
Hi Folks,
I searched this group and found an old post showing some about this
topic. Mark Grand wrote the code below:
short s;
byte b1,b2;
b1 = (byte)(s & 0xff); // low order byte
b2 = (byte)(s >>> 8); // high order byte
To convert a short into byte. I got some, but still puzzling on some.
After b1 b2 derived, how to make a new variable with them. Specially,
my goal is to handle a big number:
int pond = 204254242;
I need to convert it into a short. Well, to do this, I must truncate a
part off. In the spirit of the code showing above, I must have 4
bytes:
b1 = .....
b2 = ...
b3 = ....
b4 = ....
I certainly can do this. Then, how can put these b1~b4 together, to
create a new number that can be held in a short? Somebody can help
out? Thanks in advance!
Muddy Coder
I searched this group and found an old post showing some about this
topic. Mark Grand wrote the code below:
short s;
byte b1,b2;
b1 = (byte)(s & 0xff); // low order byte
b2 = (byte)(s >>> 8); // high order byte
To convert a short into byte. I got some, but still puzzling on some.
After b1 b2 derived, how to make a new variable with them. Specially,
my goal is to handle a big number:
int pond = 204254242;
I need to convert it into a short. Well, to do this, I must truncate a
part off. In the spirit of the code showing above, I must have 4
bytes:
b1 = .....
b2 = ...
b3 = ....
b4 = ....
I certainly can do this. Then, how can put these b1~b4 together, to
create a new number that can be held in a short? Somebody can help
out? Thanks in advance!
Muddy Coder