Java int, double, float versus C int, etc.

I'd like to know on how many bits int, double, float, long etc. are coded in Java. Is it the same in C? Where can I get information about primary types in JAVA.
Who is Participating?
pagladasuConnect With a Mentor Commented:
In Java
int - 32 bit signed two's complement
double - 64 bit IEEE 754 floating-point numbers
float - 32 bit IEEE 754 floating point numbers
long - 64 bit signed two's complement
char - 16 bit unsigned integers
boolean- 1 bit
byte- 8 bit signed two's complement
short-16 bit signed two's complement.
The size is almost similar to C. However, in most C compilers, the size of a char datatype is 8-bits. The size of an integer varies, depending on the compiler - with a 16-bit compiler, it is 16-bits, with a 32-bit compiler, it is 32-bits. Moreover, C supports unsigned integral types; Java does not.
Take a look at the book: Just Java by Peter van der Linden.

Java Language Specificaion

you can find it at
st5Author Commented:
Tks. What does "two's complement" mean? (sorry)

Two's complement is
1's complement plus 1.
It is the way, integers are stored internally and  applies especillay if you want to find out the actual value of a negative integer from the internal bit representation.
Suppose there is an internal representation of a negative integral in a 8-bit representation as follows:
  1010 1001
The most significant bit being on means that it is a negative number. However, the actual value is not -41. To get the actual value represented by it, you have to get the 2's complement as follows.
First the 1's complement. Obtained by reversing all the bits:
So 1' complement of
1010 1001 is
0101 0110 Now add 1 to get the 2's complement
0101 0111
The above pattern represents 87. So the actual value is -87. If you still need more clarifications, feel free to mail me at:


st5Author Commented:
Pagladasu: tks for this clarification. Thank you for being so kind and precise.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.