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

x
Solved

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

Posted on 1999-07-21
Medium Priority
470 Views
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.
Tks
Stéphane
0
Question by:st5
[X]
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
• 2
• 2

LVL 4

Accepted Solution

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.

thanks
0

LVL 16

Expert Comment

ID: 1246730
Java Language Specificaion

you can find it at www.javasoft.com
0

Author Comment

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

0

LVL 4

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
+1
---------------
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:
espical@hotmail.com

thanks,

0

Author Comment

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

Featured Post

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
Course of the Month8 days, 13 hours left to enroll