Search code examples
javahexbigintegerbigdecimal

Is it possible to convert a BigDecimal to Hexadecimal?


Basically title. I know you can convert BigInteger to Hex by doing BigInteger.toString(16), but you can't do the same to a BigDecimal. Is there any easy way to do this? And if not, is there a way to increase/decrease a BigInteger by a percentage?


Solution

  • BigDecimal bd = new BigDecimal(10.0001)
    String hexadecimal = bd.toBigInteger().toString(16);