当前位置:网站首页>The difference between big-endian and little-endian storage is easy to understand at a glance
The difference between big-endian and little-endian storage is easy to understand at a glance
2022-08-09 08:40:00 【running little rabbit】
Byte ordering is divided into big endian and little endian, the concepts are as follows
Big endian: The low address stores the most significant bytes.The first byte of data is stored first.
little endian: low address stores the least significant byte
stm32 is a little-endian mode, such as a 32-bit unsigned number 0x12345678,
Store 78h 56h 34h 12h sequentially from low address to high address.
1. Method and judgment of big endian and little endian
LSB means: full nameIt is the Least Significant Bit, which means the least significant bit in the binary number. Generally speaking, the MSB is located at the far left of the binary number, and the LSB is located at the far right of the binary number.
MSB means: the full name is Most Significant Bit, which belongs to the most significant bit in binary numbers, and MSB is the highest weighted bit, similar to the leftmost bit in decimal numbers.
0x12345678 Hexadecimal, two numbers are one byte The first byte of the data is 12 (MSB)
High significant byte --> Low significant byte: 12 34 56 78
Low address bits High and low address bits
Big endian: 12 34 56 78
Little Endian: 78 56 34 12
#includeint main(void ){unsigned int x =0x12345678;unsigned char *p = (unsigned char *)&x;printf("%0x %0x %0x %0x",p[0],p[1],p[2],p[3]);return 0;}
边栏推荐
猜你喜欢
随机推荐
MySQL数据库
Where does detection go forward?
I'm here to advertise
The working principle of switch
GBJ610-ASEMI超薄整流扁桥GBJ610
nyoj58 最少步数(DFS)
The principle and configuration of VLAN
【KD】2022 KDD Compressing Deep Graph Neural Networks via Adversarial Knowledge Distillation
[漏洞复现]CVE-2018-12613(远程文件包含)
Non-decreasing Array
VNCTF2021 部分题目复现
文件处理(IO)
电子产品整机结构设计的一般性思路
浅谈Flask_script
leetcode 36. 有效的数独(模拟题)
探索APP性能优化之稳定性优化(解决方案)
EMQ X 消息服务器学习记录——为后面的毕设做准备
scp上传文件到远程服务器
Use of prepareStatement
File Handling (IO)