# Need some help understanding Parsing

Printable View

• 07-15-2011, 07:52 PM
mcfer
Need some help understanding Parsing
i have this particular code

public class Numbers{
public static void main(String args[]){

Integer x =Integer.valueOf(9);
Double c = Double.valueOf(5);
Float a = Float.valueOf("80");

System.out.println(x);
System.out.println(c);
System.out.println(a);
System.out.println(b);
}
}

after execution it gives the outputs

9
5.0
80.0
1092

Could anyone explain how "1092" comes up after execution of "Integer b = Integer.valueOf( "444",16);" how does it parse the argument "444" ?

Thank you.
• 07-15-2011, 07:56 PM
Iron Lion
You specified the radix as 16. Since hexadecimal 444 is equal to decimal 1092, that's what it displays.
• 07-15-2011, 08:03 PM
mcfer
Thank you. that is understood..but radix could be any number.. let say radix=20..will it affect the output ?
• 07-15-2011, 08:07 PM
JosAH
Quote:

Originally Posted by mcfer
Thank you. that is understood..but radix could be any number.. let say radix=20..will it affect the output ?

Yup, if the radix is 20 the number 444 represents 4*(20*20)+4*(20)+4 == 1684

kind regards,

Jos
• 07-15-2011, 08:11 PM
mcfer
Thank you...
• 07-15-2011, 08:43 PM
Norm
Quote:

will it affect the output
Write a short test program and try different values and see.
• 09-26-2015, 09:53 AM
Preethi5
Re: Need some help understanding Parsing
When I give Radix=2 I'm getting an error. can you plz explain on this?
• 09-26-2015, 11:12 AM
DarrylBurke
Re: Need some help understanding Parsing
When the radix is 2, the only valid digits are 0 and 1.

db
• 09-26-2015, 11:13 AM
DarrylBurke
Re: Need some help understanding Parsing
Looks like you haven't actually understood the meaning of Radix

db