DanglingPointer
Programmer
Whats up with this?
I want to use a plain old unsigned byte 0-255, but the default Java byte type and Byte object are both signed, meaning when I use values > 200 I get value - 256.
I suppose this is something to do with how the byte represents a negative (2s complement?) but i'm not sure of the details.
the code fragment i'm using:
InetAddress ia = null;
byte[] bip = new byte[4];
Byte btmp = null;
String ip = new String();
ia = InetAddress.getByName(hostName);
bip = ia.getAddress();
for ( int i = 0; i < 4; i++ ) {
btmp = new Byte(bip);
if ( i != 3 )
ip += btmp.toString() + ".";
else
ip += btmp.toString();
}
CHeers.
I want to use a plain old unsigned byte 0-255, but the default Java byte type and Byte object are both signed, meaning when I use values > 200 I get value - 256.
I suppose this is something to do with how the byte represents a negative (2s complement?) but i'm not sure of the details.
the code fragment i'm using:
InetAddress ia = null;
byte[] bip = new byte[4];
Byte btmp = null;
String ip = new String();
ia = InetAddress.getByName(hostName);
bip = ia.getAddress();
for ( int i = 0; i < 4; i++ ) {
btmp = new Byte(bip);
if ( i != 3 )
ip += btmp.toString() + ".";
else
ip += btmp.toString();
}
CHeers.