• Post Reply Bookmark Topic Watch Topic
  • New Topic

number format exception when converting fron hex to decimal  RSS feed

 
Ranch Hand
Posts: 94
1
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Hi All,
In the above code line 1 executes fine but line 2 throws NumberFormatException.
Why is it so?

Thank You
Gajendra KM
 
Bartender
Posts: 2087
44
Firefox Browser IntelliJ IDE Java Linux Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What does X in this number mean?
Is it a valid digit for a hex number?
 
Gajendra Kangokar
Ranch Hand
Posts: 94
1
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
why is it not valid?
when it accepts F and other letters,why not X?
 
author
Sheriff
Posts: 23295
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Gajendra Kangokar wrote:why is it not valid?
when it accepts F and other letters,why not X?


The method uses the radix parameter to determine the radix... it doesn't do additional parsing of the string to determine the radix via a prefix.

And yes, it accepts "F", which has a value of 15. What is value of "X" in Hex?

Henry
 
Gajendra Kangokar
Ranch Hand
Posts: 94
1
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Henry Wong wrote:
And yes, it accepts "F", which has a value of 15. What is value of "X" in Hex?


Yes.X is an invalid character in Hex ,hence it is not determined.
Thank You Henry.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!