Less than 42 hours left in the trailboss' kickstarter!

New rewards and stretch goals. CLICK HERE!



Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Integer and int  RSS feed

 
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: 304
  • 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
Sheriff
Posts: 15859
80
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.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!