I have a small data set in HexaDecimal Representation -
byte[] bb = new byte[] { (byte)0x7D, (byte)0x44, (byte)0xCC };
To understand how the values are coming in Decimal Representation, I did the following -
Log.i("DECIMAL VALUE of 7D>>", buf[i] + "");
Log.i("DECIMAL VALUE of 44>>", buf[i+1] + "");
Log.i("DECIMAL VALUE of CC>>", buf[i+2] + "");
And what it printed was -
DECIMAL VALUE of 7D>> 125
DECIMAL VALUE of 44>> 68
DECIMAL VALUE of CC>> -52
Looking into the site -
http://hextodecimal.com/index.php?hex=CC
The Decimal Representation of byte CC
is 204
.
In my application I am getting Index Out Of Bounds Exception
just because index at -52
doesn't exist in the bounds.
So how is this byte coming negative and what is the clear solution.