前回は、修行が足りなかったみたい。
union なんて必要ありません。
メモリ上のデータの並びがわかります。
Intel だったらリトルエンディアン
#include
#include
typedef unsigned char BYTE;
using namespace std;
int main()
{
double d;
d = 1.0;
BYTE *b = reinterpret_cast
// ビッグエンディアン
for (int i = 0; i < sizeof(double); ++i)
cout << setw(2) << setfill('0') << hex << static_cast
cout << endl;
// リトルエンディアン
for (int i = sizeof(double); i != 0; --i)
cout << setw(2) << setfill('0') << hex << static_cast
cout << endl;
return 0;
}