gaoxianzhi

浮点数转换成二进制的方法

  • using namespace std;  
  •   
  • int main(){  
  •     int i;  
  •     float f=-6.9072;  
  •   
  •     //将float指针转换为字符指针  
  •     unsigned char* p=reinterpret_cast<unsigned char*>(&f);  
  •     cout<<hex;//print bytes of f in hex  
  •   
  •     for(i=0; i<sizeof(float);i++)  
  •         cout<<static_cast<int>(p[i])<<endl;  
  • }</span>  

分类:

技术点:

相关文章:

  • 2021-11-11
  • 2021-09-27
  • 2021-11-18
  • 2021-10-10
  • 2021-12-02
  • 2021-11-28
猜你喜欢
  • 2021-11-28
  • 2021-09-27
  • 2021-06-11
  • 2021-11-11
相关资源
相似解决方案