Results 1 to 4 of 4
Thread: converting hex to dec -
- 05-27-2010, 01:19 PM #1
Member
- Join Date
- May 2010
- Posts
- 15
- Rep Power
- 0
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>
- 05-27-2010, 01:23 PM #2
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
- 05-27-2010, 01:47 PM #3
Member
- Join Date
- May 2010
- Posts
- 15
- Rep Power
- 0
hi
thanks for the pointer..
I am trying to do this:
I am doing this:Java Code: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.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);
- 05-27-2010, 01:56 PM #4
I don't know what's going wrong, but this works for me:
Aaargh, parseInt not ParseInt! Java is case sensitiveJava Code:String s = "d>3ff"; s = s.substring(2); int i = Integer.parseInt(s, 16); System.out.println(i);
Math problems? Call 1-800-[(10x)(13i)^2]-[sin(xy)/2.362x]
The Ubiquitous Newbie Tips
Similar Threads
-
need help converting
By sr20guy in forum New To JavaReplies: 16Last Post: 04-02-2010, 01:07 PM -
2 converting errors
By Juicer in forum New To JavaReplies: 10Last Post: 03-06-2009, 02:58 PM -
Converting an App to Applet
By josephdcoleman in forum New To JavaReplies: 1Last Post: 02-21-2009, 07:07 AM -
Converting URL to URI
By Java Tip in forum Java TipReplies: 0Last Post: 12-26-2007, 10:15 AM -
help with converting to JApplet
By Simmy in forum AWT / SwingReplies: 2Last Post: 08-09-2007, 08:45 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks