当前位置:网站首页>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;}
边栏推荐
猜你喜欢
随机推荐
I'm here to advertise
欧几里和游戏
Arduino+2片74hc595 驱动8x8(共阳)点阵(1008BS)
Use of prepareStatement
交换机的工作原理
探索APP性能优化之稳定性优化(解决方案)
Introduction to Network Layer Protocols
PID控制电机输出作为电机PWM占空比输入的理解
Object detection app based on appinventor and EasyDL object detection API
Non-decreasing Array
Static routing principle and configuration
Euclid and the game
【redis】使用redis实现简单的分布式锁,秒杀并发场景可用
test process
文献检索作业代码
基于appinventor与EasyDL物体检测API的物体检测app
bs4之爬取诗词学习
hdu2191 多重背包(2016xynu暑期集训检测 -----B题)
路由配置转发及实验
浅谈Flask_script