プログラム開発の最近のブログ記事

前回は、修行が足りなかったみたい。
union なんて必要ありません。
メモリ上のデータの並びがわかります。
Intel だったらリトルエンディアン

#include
#include

typedef unsigned char BYTE;

using namespace std;

int main()
{
double d;
d = 1.0;
BYTE *b = reinterpret_cast(&d);

// ビッグエンディアン
for (int i = 0; i < sizeof(double); ++i)
cout << setw(2) << setfill('0') << hex << static_cast(*(b + i));

cout << endl;

// リトルエンディアン
for (int i = sizeof(double); i != 0; --i)
cout << setw(2) << setfill('0') << hex << static_cast(*(b + i));

cout << endl;

return 0;
}

暗号化技術

user-pic
票 0 票

プログラム開発: 月別アーカイブ

カテゴリ

ウェブページ

このアーカイブについて

このページには、過去に書かれたブログ記事のうちプログラム開発カテゴリに属しているものが含まれています。

前のカテゴリはネットワークです。

次のカテゴリは会社です。

最近のコンテンツはインデックスページで見られます。過去に書かれたものはアーカイブのページで見られます。