Add offset to hex

M

mike

Hi,

I have a base represented as:

0x011B0000

To this I have to add an offset represented as this:

0x5900

How can I add the offset and see the resulting hex code?

br,

//mike
 
L

Lew

mike said:
I have a base represented as:

0x011B0000

What does how it's represented matter?
To this I have to add an offset represented as this:

0x5900

How can I add the offset and see the resulting hex code?

Add the two numbers then display the result in hex.

There's more than one way to display the result in hex. The simplest might be
to use
<http://java.sun.com/javase/6/docs/api/java/lang/Integer.html#toHexString(int)>

System.out.println( Integer.toHexString( 0x011B0000 + 0x5900 ));

The String representation of an 'int' has absolutely nothing whatsoever at all
in the least to do with how to calculate with it. An integer is an integer is
an integer regardless of the numerals used to represent its value.

A number and a numeral are not the same thing.

It is a good idea to get very familiar with the fundamental Java API, such as
java.lang.*, java.util.* and java.io.*. Those fall under the category of
elementary Java knowledge. Read and study the Javadocs for those packages and
their classes.
 
R

Roedy Green

How can I add the offset and see the resulting hex code?

arithmetic is always done in binary (e.g. long, int) You problem is
then how to convert he two hex Strings to binary, and to convert the
binary back to a hex String.

For the code snippets you will need, see
http://mindprod.com/jgloss/hex.html
--
Roedy Green Canadian Mind Products
http://mindprod.com

There is no harm in being sometimes wrong especially if one is promptly found out.
~ John Maynard Keynes (born: 1883-06-05 died: 1946-04-21 at age: 62)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,012
Latest member
RoxanneDzm

Latest Threads

Top