fork download
  1. import java.util.*;
  2. import java.lang.*;
  3. import java.io.*;
  4.  
  5. class Ideone {
  6. public static void main (String[] args) throws java.lang.Exception {
  7. for (double d : new double [] {0., 2., -2., 4503599627370496., 9007199254740992., 9007199254740994., 75.38}) {
  8. String bits = Long.toBinaryString(Double.doubleToLongBits(d));
  9. bits = "0".repeat(64 - bits.length()) + bits;
  10.  
  11. String m = bits.substring(12);
  12.  
  13. System.out.println(d);
  14. System.out.println(bits);
  15. System.out.println(m);
  16. System.out.println();
  17. }
  18. }
  19. }
Success #stdin #stdout 0.11s 36372KB
stdin
Standard input is empty
stdout
0.0
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000

2.0
0100000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000

-2.0
1100000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000

4.503599627370496E15
0100001100110000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000

9.007199254740992E15
0100001101000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000

9.007199254740994E15
0100001101000000000000000000000000000000000000000000000000000001
0000000000000000000000000000000000000000000000000001

75.38
0100000001010010110110000101000111101011100001010001111010111000
0010110110000101000111101011100001010001111010111000