Results 1 to 4 of 4
  1. #1
    Symbiot is offline Member
    Join Date
    May 2010
    Posts
    15
    Rep Power
    0

    Default converting hex to dec -

    Hi

    I am getting some hex data from a processor, and need it converted to decimal.

    I am stripping 2 chars from the input and parsing the rest into a 'line'

    So in my 'line' I have 3ff or similar.

    I need this converted to decimal...

    I seem to have hit a wall.. All I can find is dec to hex when looking through java docs..

    What should I be reading?

    I have no code to show so far... <blank>

  2. #2
    PhHein's Avatar
    PhHein is offline Senior Member
    Join Date
    Apr 2009
    Location
    Germany
    Posts
    1,429
    Rep Power
    7

    Default

    int java.lang.Integer.parseInt(String s, int radix)
    Math problems? Call 1-800-[(10x)(13i)^2]-[sin(xy)/2.362x]
    The Ubiquitous Newbie Tips

  3. #3
    Symbiot is offline Member
    Join Date
    May 2010
    Posts
    15
    Rep Power
    0

    Default

    hi

    thanks for the pointer..

    I am trying to do this:

    Java Code:
    int d = Integer.ParseInt(line, 16);
    I am doing this:

    Java Code:
    char[] char_array = new char[output.length()];
            
                   char_array = output.toCharArray();         
                   
                   
                    for ( int i = 2; i < char_array.length; i++ )      
                  
                    {
                       line = line + char_array[i];
    
    
    int d = Integer.ParseInt(line, 16);
    then I want to take line, which contains the hex and convert it to dec, but I think I am missing the syntax of ParseInt.

  4. #4
    PhHein's Avatar
    PhHein is offline Senior Member
    Join Date
    Apr 2009
    Location
    Germany
    Posts
    1,429
    Rep Power
    7

    Default

    I don't know what's going wrong, but this works for me:
    Java Code:
    String s = "d>3ff";
    s = s.substring(2);
    int i = Integer.parseInt(s, 16);
    System.out.println(i);
    Aaargh, parseInt not ParseInt! Java is case sensitive
    Math problems? Call 1-800-[(10x)(13i)^2]-[sin(xy)/2.362x]
    The Ubiquitous Newbie Tips

Similar Threads

  1. need help converting
    By sr20guy in forum New To Java
    Replies: 16
    Last Post: 04-02-2010, 02:07 PM
  2. 2 converting errors
    By Juicer in forum New To Java
    Replies: 10
    Last Post: 03-06-2009, 03:58 PM
  3. Converting an App to Applet
    By josephdcoleman in forum New To Java
    Replies: 1
    Last Post: 02-21-2009, 08:07 AM
  4. Converting URL to URI
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 12-26-2007, 11:15 AM
  5. help with converting to JApplet
    By Simmy in forum AWT / Swing
    Replies: 2
    Last Post: 08-09-2007, 09:45 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •