fork(5) download
  1. #include<stdio.h>
  2. #include<stdint.h>
  3. #include<float.h>
  4.  
  5. int main(){
  6.  
  7. // 以下是 0.00390625 二進位表示(IEEE 754)
  8. char *str = "0011111101110000000000000000000000000000000000000000000000000000";
  9.  
  10. double b = 0;
  11.  
  12. uint64_t *ptr = (uint64_t*)&b;
  13.  
  14. int i;
  15.  
  16. for(i = 0; i <= 63; ++i){
  17. *ptr |= ((uint64_t)1 << (63 - i)) * (str[i] - '0');
  18. }
  19.  
  20. printf("%.*f\n",DBL_DIG,b);
  21.  
  22. return 0;
  23. }
Success #stdin #stdout 0s 16064KB
stdin
Standard input is empty
stdout
0.003906250000000