s_lavie
asked on
BigInteger and byte array
How I can represent the following 8 bytes in a byte[] 0x00ff000000000000 ?
In other words, I want something like:
byte[] myBytes = { 00, ff, 00, 00, 00, 00, 00, 00 };
I know 0xff is an unsigned byte and I can use char as its type, but I want to construct a BigInteger with that array.
BigInteger bi = new BigInteger(myBytes);
Any suggestions?
In other words, I want something like:
byte[] myBytes = { 00, ff, 00, 00, 00, 00, 00, 00 };
I know 0xff is an unsigned byte and I can use char as its type, but I want to construct a BigInteger with that array.
BigInteger bi = new BigInteger(myBytes);
Any suggestions?
ASKER
> What's your problem?
initiate that array when one of the entries is 0xff
initiate that array when one of the entries is 0xff
byte[] myBytes = { 0x00b, 0xffb, 0x00b, 0x00b, 0x00b, 0x00b, 0x00b, 0x00b };
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Does (byte)0xff can cause any harm?
no - it simply gets the lowes byte from the integer value - which is exactly what you want
ASKER
Thank you all
The above is ok. One of the constructors takes a byte array.
What's your problem?