Unexpected NumberFormatException while parsing a hex string to an int value

后端 未结 5 1482
小鲜肉
小鲜肉 2021-01-26 02:22

I want to parse an String containing 8 hex-digits (4bytes) but i got an NumberFormatException. What is wrong here?

assertThat(Integer.parseInt(\"FFFF4C6A\",16),i         


        
5条回答
  •  执念已碎
    2021-01-26 03:03

    I don't know the assertThat() method, but your hexadecimal number "FFFF4C6A" is to big for an integer.

    For example, if you write :

    int number = Integer.parseInt("FFFF4C6A",16)

    you'll get the same error. A correct way to write the code would be :

    double number = Integer.parseInt("FFFF4C6A",16)

提交回复
热议问题