Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


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

Posted on 1999-07-21
Medium Priority
Last Modified: 2012-06-27
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.
Question by:st5
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2

Accepted Solution

pagladasu earned 150 total points
ID: 1246729
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.

LVL 16

Expert Comment

ID: 1246730
Java Language Specificaion

you can find it at

Author Comment

ID: 1246731
Tks. What does "two's complement" mean? (sorry)


Expert Comment

ID: 1246732
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:



Author Comment

ID: 1246733
Pagladasu: tks for this clarification. Thank you for being so kind and precise.

Featured Post

The top UI technologies you need to be aware of

An important part of the job as a front-end developer is to stay up to date and in contact with new tools, trends and workflows. That’s why you cannot miss this upcoming webinar to explore the latest trends in UI technologies!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
The viewer will learn how to implement Singleton Design Pattern in Java.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Suggested Courses

721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question