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 numbers, that Long can't store them i.e 2^900
.
相关问题
- Delete Messages from a Topic in Apache Kafka
- Jackson Deserialization not calling deserialize on
- How to maintain order of key-value in DataFrame sa
- StackExchange API - Deserialize Date in JSON Respo
- Difference between Types.INTEGER and Types.NULL in
You can use a BigInteger to hold your large number and the BigInteger.toString() method to retrieve a binary representation of it.
Have you tried using
java.math.BigInteger
and callingtoString(int radix)
with a parameter of 2?You can use Double.toHexString(d) and then transform the hexadecimal string into a binary one using a for loop and a StringBuilder.
Long.toBinaryString(Double.doubleToRawLongBits(d))
appears to work just fine.You may want to process whole and fractional part :