I'm trying ton convert Hex into decimal and into binary but getting same error for given HEX "001F012900F3ADA3"
but same hex is converted to decimal and into binary using any online convertor.
Integer.parseInt("001F012900F3ADA3",16); // to decimal conversion
Integer.toBinaryString(Integer.parseInt("001F012900F3ADA3", 16)); // to binary conversion
when i use part of this HEX like Integer.parseInt("00F3ADA3",16);
this works fine no exception.
is there some type of max hex length allowed to convert or i'm using something wrong please correct me.
CodePudding user response:
The value that you're trying to parse is too big to fit in integer. To parse this properly you'd have to parse it as long.
If you replace it with below, then it'll work.
Long.toBinaryString(Long.parseLong("001F012900F3ADA3", 16));
CodePudding user response:
The max value of int is 2147483647
, value : 001F012900F3ADA3
convert to the Binary number is 8726999899286947
.