S
Spendius
Hi,
I'm back again with my array of bytes conversion procedure
because I've noticed that, using:
I DON'T GET THE SAME RESULTS whether I read the bytes from
a file, or manually check it, i.e. explicitly write the code:
1rst case:
b[0]: 0x85
b[1]: 0xf4
val: 34292 // <= OK this is what I expect
(BUT ! 2389 returned when read from a file but I do see
"00 00 85 f4" with 'od')
2nd case:
b[0]: 0x7e
b[1]: 0xf6
val: 32502 // <= OK this is what I expect
(BUT ! 646 returned when read from a file but I do see
"00 00 7e f6" with 'od')
Can *please* someone tell me WHY the result differs when I test
my procedure with an array fed from an file InputStream and when
fed manually with the code 'b[x] = 0x..' ??
Thanks.
I'm back again with my array of bytes conversion procedure
because I've noticed that, using:
int val;
for (int k=b.length-1, j=0; k>=0; k--, j++)
val += (b[k] & 0xff) << (8*j);
System.out.println("val: "+val);
I DON'T GET THE SAME RESULTS whether I read the bytes from
a file, or manually check it, i.e. explicitly write the code:
I get the following:byte b[] = new byte[2];
b[0] = 0x85; // 7e
b[1] = 0xf4; // f6
1rst case:
b[0]: 0x85
b[1]: 0xf4
val: 34292 // <= OK this is what I expect
(BUT ! 2389 returned when read from a file but I do see
"00 00 85 f4" with 'od')
2nd case:
b[0]: 0x7e
b[1]: 0xf6
val: 32502 // <= OK this is what I expect
(BUT ! 646 returned when read from a file but I do see
"00 00 7e f6" with 'od')
Can *please* someone tell me WHY the result differs when I test
my procedure with an array fed from an file InputStream and when
fed manually with the code 'b[x] = 0x..' ??
Thanks.