#include <iostream> #include <bitset> using namespace std; int main() { int x=-101; bitset<32> B(x); cout<<B<<endl; cout<<"16進位表達:"<<hex<<B.to_ulong()<<endl; float f=-101;// //reinterpret_cast 將一種型態的指標轉換為另一種型態的指標 bitset<32> BF(*reinterpret_cast<unsigned long*>(&f)); cout<<BF<<endl;//這就是儲存float f的方式 cout<<"16進位表達:"<<hex<<BF.to_ulong()<<endl; return 0; }