File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Signed and Unsigned int

 
T Ko
Greenhorn
Posts: 1
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The value 2147483647 is the max. value of a value i which is defined as int. Also the value of -1 when assigned to a unsigned int , it will 2147483647. How can we find the 2147483647 is actually represents -1 when we consider unsigned integers. Is there any function which converts unsigned int to signed int and vice versa.
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In Java, all numeric primitives are signed. There is no such thing as an unsigned int.

A Java int is 32 bits. So the binary representation of -1 as an int is 32 ones, which translates to 4294967295 in base 10 (that is, (2^32)-1).

But 2147483647 is only (2^31)-1. This is the largest positive value of a Java int.
[ April 25, 2005: Message edited by: marc weber ]
 
Tony Morris
Ranch Hand
Posts: 1608
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The largest positive value is 2^31-1.
Here's some fun:
http://qa.jtiger.org/GetQAndA.action?qids=15&showAnswers=false
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic