题解 | #嵌入式机器的大小端#
嵌入式机器的大小端
https://www.nowcoder.com/practice/0188fa9d749f4904b14367e965f83b0d
/**
* 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
*
*
* @param n int整型
* @return int整型
*/
int judge(int n ) {
// write code here
n = 0x1234; //通过一个多字节数字来判断数据存储的顺序
/*大端模式
0x1234
内存低地址 --------------------> 内存高地址
0x12 | 0x34
高位字节 <-------------------- 低位字节
/
n >>= 8; //右移位8位 0x12 0x34(大端) 0x34 0x12 (小端)
if (n == 0x12){
return 1;
}
else{
return 0;
}
}