Part 5 – Data representation in Computer memory
July 21, 2020 2 min read

In last article we discussed about the Java define data types. Today we going to learn about How the data represent in computer memory.
1. Integer

Bit is a digital communication as well as a basic unit that gives information of computing. It is most commonly represent by 0 and 1. That means binary. There the decimal is converting to a binary number as shown in the above image. Let’s see an example.

100 (decimal) – 01100100 (binary)
Negative values are from 2s complement theory.
+100 (8bits) 01100100
1s Complement 10011011 (Mirror side of above binary value)
2s Complement +1 (Add 1 to the 1s complement)
The answer is 10011100 (binary) of -100
-128 and 128 have similar binary values and sign bit because the limit of 8 bits is between -128 and 127. Try to get the binary values of 128 and -128
| Data Type | Byte | Short | Int | Long |
| No.of bits | 8 | 16 | 32 | 64 |
| Max. Value | 27 – 1 | 215 – 1 | 231 – 1 | 263 – 1 |
| Min. Value | -27 | -215 | -231 | -263 |
| Bit pattern of max. | 01111111 | 0(1-15) | 0(1-31) | 0(1-63) |
| Bit pattern of min. | 10000000 | 1(0-15) | 1(0-31) | 1(0-63) |
2. Floating point (IEEE – 752)
eg : double d = 123400000.0;

0.1234 x 109 = 0.1234E9
Mantissa part is taking as a decimal number and last 8 bits are taking as the exponent part. Here 0.1234 is the mantissa part. But the computer take it as 0.1234E9. E means Exponent.
3. Characters
To assign a character value to a character variable, Americans created a code called “ASCII ( American Standard Information Interchange)”.
eg: A – 65, a – 97, 0 – 48, 1 – 49
Because character has no negative or positive value, there is no sign bit.
4.Boolean data
Boolean has only 1 bit. Therefore it is representing as 1 or 0. That means true or false.
Guys, We finished the learning of data representation for some extent. We have to learn more. Let’s learn them in future articles.
See you in the next article with the topic Java literals.
Thank you.


