-
Notifications
You must be signed in to change notification settings - Fork 1
なんとかエンディアン
elipmoc edited this page Aug 4, 2017
·
2 revisions
176849379を32bitのint型とする。
これを2進数に変換すると
00001010100010101000000111100011
8bitごとに区切ると
00001010 / 10001010 / 10000001 / 11100011
それぞれを補数を考慮して10進数に直すと
10 / -118 / -127 / -29 となる
これをc言語でバイト単位で取得すると
int a=176849379;
char* temp;
char* p;
p=(char*)&a;
for(int i=0;i<4;i++)
{
temp=(char*)p;
printf("%d\n",*temp);
p++;
}
で、 出力結果は-29,-127,-118,10という逆順になる。
だから多分リトルエンディアンなんだろうなあ。