This week's book giveaway is in the OCAJP 8 forum.
We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line!
See this thread for details.
The moose likes Java in General and the fly likes hexadecimal unsigned integer Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "hexadecimal unsigned integer" Watch "hexadecimal unsigned integer" New topic

hexadecimal unsigned integer

Sean Casey
Ranch Hand

Joined: Dec 16, 2000
Posts: 625
I have a list of 32 bit instructions that are in hexadecimal. I've been storing them in integers. My problem is that the hexadecimal instructions are unsigned (they are only positive), and a java integer is signed, so a couple of the instructions are coming up negative. Is there a way to make them unsigned like in C ?
Michael Morris
Ranch Hand

Joined: Jan 30, 2002
Posts: 3451
You could store them as ints and process them as longs using a mask to make the longs unsigned. For example:

Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius - and a lot of courage - to move in the opposite direction. - Ernst F. Schumacher
I agree. Here's the link:
subject: hexadecimal unsigned integer
jQuery in Action, 3rd edition