st5
asked on
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.
Tks
Stéphane
Tks
Stéphane
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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
+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,
pagladasu
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,
pagladasu
ASKER
Pagladasu: tks for this clarification. Thank you for being so kind and precise.
you can find it at www.javasoft.com