Java converting int to hex and back again

前端 未结 10 1121
鱼传尺愫
鱼传尺愫 2020-11-28 08:34

I have the following code...

int Val=-32768;
String Hex=Integer.toHexString(Val);

This equates to ffff8000

int         


        
10条回答
  •  执念已碎
    2020-11-28 09:08

    Below code would work:

    int a=-32768;
    String a1=Integer.toHexString(a);
    int parsedResult=(int)Long.parseLong(a1,16);
    System.out.println("Parsed Value is " +parsedResult);
    

提交回复
热议问题