#include <stdlib.h>
#include <stdio.h>
#include <stdint.h>

typedef union
{
   double f;
   uint32_t i[2];
}Packet;

#define M  ((1<<20)-1)
void test( double f)
{
  Packet p;
  p.f=f;
  printf("f1 = %.16f ~= (1.0+%u/2^20)*2^%u\n", p.f, p.i[1]&M, (p.i[1]>>20)-1023 );
}

int main(int argc, char* argv[] )
{
   double f;
   printf("Please input a double?");
   scanf("%lf",&f);
   test(f);
   return 0;
}

C++双精度浮点格式,仅供参考

相关文章:

  • 2021-11-04
  • 2022-12-23
  • 2021-09-29
  • 2022-01-01
  • 2022-12-23
  • 2022-12-23
  • 2021-11-18
  • 2021-07-15
猜你喜欢
  • 2021-09-14
  • 2022-12-23
  • 2021-10-12
  • 2022-12-23
  • 2022-02-12
  • 2022-01-01
  • 2021-06-07
相关资源
相似解决方案