Add offset to hex

Discussion in 'Java' started by mike, Jun 14, 2010.

  1. mike

    mike Guest

    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
     
    mike, Jun 14, 2010
    #1
    1. Advertising

  2. mike

    Lew Guest

    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
     
    Lew, Jun 14, 2010
    #2
    1. Advertising

  3. mike

    Roedy Green Guest

    On Mon, 14 Jun 2010 01:44:06 -0700 (PDT), mike
    <> 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)
     
    Roedy Green, Jun 14, 2010
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    10
    Views:
    6,211
    Neredbojias
    Aug 19, 2005
  2. Lance Riedel

    Translated Offset to Source Offset

    Lance Riedel, Oct 14, 2003, in forum: XML
    Replies:
    2
    Views:
    502
    Patrick TJ McPhee
    Oct 15, 2003
  3. Bengt Richter
    Replies:
    6
    Views:
    471
    Juha Autero
    Aug 19, 2003
  4. jack
    Replies:
    4
    Views:
    588
  5. Roy Smith
    Replies:
    4
    Views:
    276
    Roy Smith
    Jan 27, 2013
Loading...

Share This Page