0
我試圖將小端轉換爲大端並且遇到問題。 我有一個數組,有2個字節的無符號字符,這是十六進制值。 ,我想使它由零的大端已消失,我不能得到我想要的值。轉換小端到大端包括0(零)
例如, 我的目標是讓
array[0] = 0b
array[1] = 40
output = 0b40 so i can see this value as 2880 when %d
所以我用
output = (array[1]>>4) | (array[0]<<4);
但在現實中,我看到
printf("output = %x04\n", output);
output = 00b4
我想要的輸出爲0b40所以我可以得到2880當我做
對printf("output = %x\n", output);
output = 0b40
printf("output = %d\n", output);
output = 2880
謝謝你們的任何幫助將不勝感激