问题
I am generating sequence of numbers of type double like 0.9913963644564902 0.0341175990344773 0.13181105852355268 0.45773616980747556 and I have to convert it to binary representation in java.
回答1:
This will help you. I have tried out using one of your input double value - 0.9913963644564902
public static void main(String[] args){
double d = 0.9913963644564902;
System.out.println("0b"+Long.toBinaryString(Double.doubleToRawLongBits(d)));
}
The output would be
run:
0b11111111101111101110011000010011011110010101101101100001110011
BUILD SUCCESSFUL (total time: 0 seconds)
来源:https://stackoverflow.com/questions/20730179/converting-double-to-binary-in-java