public class test {
public static void main(String[] args) {
int i=273;
byte b = (byte)i;
System.out.println("Result "+b);
}
}
when i compiled the program the result was 17...
:-/
public class test {
public static void main(String[] args) {
int i=273;
byte b = (byte)i;
System.out.println("Result "+b);
}
}
when i compiled the program the result was 17...
:-/
A byte is 8 bits. It can hold values from 0 to 255. If you try to store 256, that's the same as storing 0. 273 = 0x111. The "byte" is the last two hex digits , or 0x11, which is 17 in decimal. The leading 1 is not stored because there is no room.
A byte is 8 bits. It can hold values from 0 to 255. If you try to store 256, that's the same as storing 0. 273 = 0x111. The "byte" is the last two hex digits , or 0x11, which is 17 in decimal. The leading 1 is not stored because there is no room.
thanx a bunch:)
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.