@@ -327,19 +327,21 @@ Joda Date api
327327
328328##java Data Type deep concept
329329 ----------------------------------------------
330- java contain 8 data type(primitives)
331- 6 type for number - 6(byte-1Byte,short-2Byte,int-4Byte,long-8Byte,float-4Byte,double-8Byte)
332- 1 type for boolean (boolean-1bit) [0,1]
333- 1 type for character(char-2byte) --only positive num[0-(2^16-1)] = [0 to 65535]
334- for byte -contains both negative & positive -- so in 1 byte = 8 bits
335- total possible number using 8 bit = 2^8 = 256 means half number should be negative and half number should be positive
336- first negative number; 256/2 = -128
337- last postive number = 256 -(128+1) = 127
338- so validate range [-128,127]
339- formula = total possible = (last-first+1) = 256 = 127-(-128)+1=256
340- 1 added because zero belongs to positive number
341- note: always java store negative num inform of 2's complement.
342-
330+
331+ java contain 8 data type(primitives)
332+ 6 type for number - 6(byte-1Byte,short-2Byte,int-4Byte,long-8Byte,float-4Byte,double-8Byte)
333+ 1 type for boolean (boolean-1bit) [0,1]
334+ 1 type for character(char-2byte) --only positive num[0-(2^16-1)] = [0 to 65535]
335+ for byte -contains both negative & positive -- so in 1 byte = 8 bits
336+ total possible number using 8 bit = 2^8 = 256 means half number should be negative
337+ and half number should be positive
338+ first negative number; 256/2 = -128
339+ last postive number = 256 -(128+1) = 127
340+ so validate range [-128,127]
341+ formula = total possible = (last-first+1) = 256 = 127-(-128)+1=256
342+ 1 added because zero belongs to positive number
343+ note: always java store negative num inform of 2's complement.
344+
343345 //2s complement rules => reverse all bit from left to right plus
344346 change all zero to 1 from left to right till 1st one
345347 example:
0 commit comments