programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
• Campbell Ritchie
• Tim Cooke
• Devaka Cooray
• Ron McLeod
• Jeanne Boyarsky
Sheriffs:
• Liutauras Vilda
• paul wheaton
• Junilu Lacar
Saloon Keepers:
• Tim Moores
• Stephan van Hulst
• Piet Souris
• Carey Brown
• Tim Holloway
Bartenders:
• Martijn Verburg
• Frits Walraven
• Himai Minh

# number format exception when converting fron hex to decimal

Ranch Hand
Posts: 94
1
• Number of slices to send:
Optional 'thank-you' note:

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: 2236
63
• Number of slices to send:
Optional 'thank-you' note:
What does X in this number mean?
Is it a valid digit for a hex number?

Gajendra Kangokar
Ranch Hand
Posts: 94
1
• Number of slices to send:
Optional 'thank-you' note:
why is it not valid?
when it accepts F and other letters,why not X?

author
Posts: 23928
142
• Number of slices to send:
Optional 'thank-you' note:

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
• Number of slices to send:
Optional 'thank-you' note:

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.

 This tiny ad is guaranteed to be gluten free. the value of filler advertising in 2021 https://coderanch.com/t/730886/filler-advertising