Last active
June 25, 2022 05:08
-
-
Save fabienhinault/412cef7f5217f958d1f59c75951e5830 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class Main { | |
| public static void main(String[] args) { | |
| System.out.println(Long.toBinaryString(Double.doubleToLongBits(1650e-9))); | |
| System.out.println(Long.toBinaryString(Double.doubleToLongBits(1650e-9)).length()); | |
| System.out.println(Long.toBinaryString(Double.doubleToLongBits(-1650e-9))); | |
| System.out.println(Long.toBinaryString(Double.doubleToLongBits(-1650e-9)).length()); | |
| } | |
| } | |
| // 1111101011 1011101011101011001000101111100100101001010011000011 | |
| // 62 | |
| // 1011111010111011101011101011001000101111100100101001010011000011 | |
| // 64 | |
| ////////////// | |
| // 01111101011 = 1003 https://www.binary-code.org/binary/11bit/01111101011/ | |
| // 1011101011101011001000101111100100101001010011000011 = 3288305069364419 | |
| // x = 2^(1003-1023) (1 + 3288305069364419/2^52) = | |
| // 7791904696734915 / 4722366482869645213696 = | |
| // 1.6500000000000000841530621228936404065734677715227007865905... × 10^-6 | |
| // https://www.wolframalpha.com/input?i=2%5E-20+%281+%2B+3288305069364419%2F2%5E52%29 | |
| // |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment