Saturday, 29 December 2018

data types in java

Data Types in Iava


byte :-

Size=8 – bits
  Where as 1 bits= msb
1
1
1
1
1
1
1
1
1


Signbit
0 to +127
1 to -128
0->+ve
1->-ve

Max _value=127
Min_value=-128
Range =-128 to +127
The most Significant Bit is called Signbit. 0 means +ve value and 1 means –ve
Value
+ve numbers represent directly in the memory  where as –ve numbers represented in 2’s complement form.
Ie:
byte b=100;
byte b=127;
byte b=130  possible loss of precision found int required byte.

Byte data type  is best suitable if we want to handle data in terms of stream either from the file or from the network.

No comments:

Post a Comment