• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Integer and int

 
nimo frey
Ranch Hand
Posts: 580
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is that true, that Integer can only handles value between −32.768 till 32.767 and unsigned till 65.535.

And int can handle values till 4.294.967.295 (unsigned) ?
 
Albareto McKenzie
Ranch Hand
Posts: 299
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Nimo

Try this:

System.out.println(Integer.MAX_VALUE);
System.out.println(Integer.MIN_VALUE);

What do you get?

For your other question about int type:

http://java.sun.com/docs/books/tutorial/java/nutsandbolts/datatypes.html



 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15441
41
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Java does not have unsigned integer types (apart from char) like C or C++ has.

And what you say about Integer is not correct; class Integer is just a wrapper class for int. See The Numbers Classes in Sun's Java Tutorials.

An int in Java is 32 bits and is encoded in [url=http://en.wikipedia.org/wiki/Two%27s_complement]two's complement[/url] format, so it can hold values from -2^31 to 2^31 - 1.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic