From: mike on
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
From: Lew on
mike wrote:
> 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.

--
Lew
From: Roedy Green on
On Mon, 14 Jun 2010 01:44:06 -0700 (PDT), mike
<mikaelpetterson(a)hotmail.com> wrote, quoted or indirectly quoted
someone who said :

>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)