my dog learned polymorphism
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

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’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link:
subject: hexadecimal unsigned integer
It's not a secret anymore!