Author Topic:   Integer types
posted April 24, 2000 02:51 PM           
Hi Maha, Jim and All:
Java ranch short story says that integer types are signed

I am confused here because char type is also integer type and unsigned.

So if the question says, integer types are signed. Is it true or false.

Please help


maha anna
posted April 24, 2000 03:32 PM             
We can't say all interger types in java are signed. It is false. The 'char' type does come under Integral type. JLS gives a break-down of all the primitives in Jave here. It in fact clearly says that 'char' is unsigned and it is part of integral type.

I brifely saw the link you posted here. The portion which says it is SIGNED implies only byte/short/int/long. Further down it says char is UNSIGNED.

Please refer to JLS here

I wait for Paul for his response regarding this.

[This message has been edited by maha anna (edited April 24, 2000).]

Suma Narayan
ranch hand
posted April 24, 2000 04:12 PM         
Hi Maha,

I have been reading Beginning Java2 by IVOR HORTON. This is suppose to be one of the Best books for JAVA.In this book, the author says the following:

JAVA language provides 8 basic data types.These fundamental types, also called as primitives, allow you to define variables for storing data that falls into one of three categories:

- Numeric values, which can be either integer or floating
- Variables which store a single Unicode character.
- Logical variables that can assume the value true or false.

Integer Data Types:

There are four types of variables that you can use to store integer data. ALL OF THESE ARE SIGNED. The four integer types in Java are:


Now, I am also confused as JLS says something else. I do not know which one to follow.

Paul Wheaton
posted April 25, 2000 07:15 AM             
byte, short, int and long are all signed. char is not signed.

The cups story read:

byte - 8 bits
short - 16 bits
int - 32 bits
long - 64 bits

All the integer types are SIGNED.

And later it says that char is unsigned. But I can see how there might be some room for confusion, so I changed the above to

All of these integer types are SIGNED.


maha anna
posted April 25, 2000 10:18 AM             
Yes. Now better. So your vote is for All integral types in Java are SIGNED right?

maha anna

Tony Alicea
posted April 25, 2000 06:34 PM             
Mine it isn't.

I say (because I think the JLS says it) that char is the only integral type that is unsigned. I wish I had the time to look it up and post the URL...