当前位置:网站首页>大端小端存储区别一看即懂
大端小端存储区别一看即懂
2022-08-09 08:33:00 【奔跑的小赛兔】
字节排序按分为大端和小端,概念如下
大端(big endian):低地址存放高有效字节。数据的第一个字节先存。
小端(little endian):低地址存放低有效字节
stm32是小端模式,如一个32位无符号数0x12345678,
从低地址到高地址依次储存 78h 56h 34h 12h。
1.大端和小端的方式及判断
LSB的意思是:全称为Least Significant Bit,在二进制数中意为最低有效位,一般来说,MSB位于二进制数的最左侧,LSB位于二进制数的最右侧。
MSB的意思是:全称为Most Significant Bit,在二进制数中属于最高有效位,MSB是最高加权位,与十进制数字中最左边的一位类似。
0x12345678 16进制,两个数就是一字节 数据的第一个字节是12(MSB)
高有效字节——>低有效字节: 12 34 56 78
低地址位 高低址位
大端: 12 34 56 78
小端: 78 56 34 12
#include<stdio.h>
int 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;
}
边栏推荐
猜你喜欢
Dark Horse 2022 latest redis course notes and knowledge points (for interview)
如何生成dll文件 采用VS2017生成dll文件(动态库文件)和lib文件(静态库文件)以C语言为例
MySQL数据库
网络层协议介绍
Notes on OpenHarmony Open Source Meeting (Nanjing Station)
正则之re模块
leetcode 36. 有效的数独(模拟题)
磁盘管理与挂载
Object detection app based on appinventor and EasyDL object detection API
Introduction to the Endpoint
随机推荐
jdbctemplate连接sql server,代码中查出来的数据跟数据库中不一致,如何解决?
GBJ610-ASEMI超薄整流扁桥GBJ610
web基本概念
欧几里和游戏
Different styles of Flask-restful
System Security and Application
数据库MySQL的安装和卸载
pip3换源提升速度
requests之数据解析Xpath介绍
scp上传文件到远程服务器
我这是来宣传一下
The MySQL database
【GNN】2022 G-Mixup: Graph Data Augmentation for Graph Classification
VLAN的原理及配置
Dark Horse 2022 latest redis course notes and knowledge points (for interview)
DeFi 项目中的治理Token
Account and Permission Management
mysql事务(详解)
IO字节流读取文本中文乱码
C语言笔记 学习预处理 学习宏定义