4 Replies Latest reply: Sep 29, 2006 12:37 AM by 807569 RSS

    Hex to Int

    807569
      Hey guys, can someone help me out here ..... i need to convert hex to int. I'm relatively new to java. Kindly bail me out here
        • 1. Re: Hex to Int
          807569
          Integer class has two parseInt methods. One takes a single parameter and one takes two parameters. Go take a look.
          • 2. Re: Hex to Int
            807569
            Check out the Integer static method with the signature:
            public static int parseInt(String s, int radix) throws NumberFormatException

            You should note that "int" is a primitive java type for (nonfactional)
            numbers, and "hex" is (presumably) a String. That is they are very
            different sorts of thing. The "radix" in the method referred to above
            is 16 in the case of hex strings.

            There is also a static decode(String) method.

            You can read about both here: http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Integer.html
            • 3. Re: Hex to Int
              807569
              What ever happened to making them look things up for themselves. You know you are one step away from Norweed. ;)
              • 4. Re: Hex to Int
                807569
                You know you are one step away from Norweed. ;)
                Wounded!

                Watch out or I'll tell the guy in the "Need help quick" thread as well ;)