Convert Double to Binary representation?

后端 未结 6 1597
深忆病人
深忆病人 2020-11-28 16:04

I tried to convert a double to its binary representation, but using this Long.toBinaryString(Double.doubleToRawLongBits(d)) doesn\'t help, since I have large nu

6条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-11-28 16:23

    You can use a BigInteger to hold your large number and the BigInteger.toString() method to retrieve a binary representation of it.

    BigInteger bigNum = new BigInteger(sYourNum);
    System.out.println( bigNum.toString(2) );
    

提交回复
热议问题