当前位置:网站首页>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;}
边栏推荐
猜你喜欢
随机推荐
Static routing principle and configuration
requests之模拟登录学习
Account and Permission Management
web basic concepts
test process
BUUCTF MISC刷题笔记(一)
Servlet的实现原理解析(serverapplet)(服务端程序)
OpenHarmony轻智能产品开发直播笔记
系统安全及应用
引导过程与服务控制
Processes and Scheduled Tasks
elder blind date
数制之间的转换
【CNN】2022 ECCV 对比视觉Transformer的在线持续学习
Regular Expressions for Shell Programming
The Servlet,
数据库中的操作(语法)
Where does detection go forward?
+ 6000 words, help you understand the Internet architecture evolution.
IO字节流读取文本中文乱码