当前位置:网站首页>Byte order: big endian vs little endian
Byte order: big endian vs little endian
2022-06-23 01:38:00 【summer_ sunrise】
How to quickly remember
big-endian also called Large tail sequence , The tail of the value is stored in the large address . The tail is relative to the variable value we know , Large means address ;
Corresponding ,little-endian also called Little endings , The tail of the value is stored in a small address .
In a word, size is the address of the tail , The tail is the tail of numbers , refer to 0xABCD( Decimal system 43981) Of D

How to determine whether the byte order is large or small
- View through binary tools : readelf -h main
int main(){
return 0;
}
Compile binary
g++ main.cpp -o main
Use readelf Check byte order
readelf -h main
give the result as follows (ELF Magic The first 6 Bytes represent byte order ,0 Invalid format ; 1 Small end format ; 2 Big end format )
ELF Header:
Magic: 7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00
Class: ELF64
Data: 2’s complement, little endian
Version: 1 (current)
OS/ABI: UNIX - System V
ABI Version: 0
Type: DYN (Shared object file)
Machine: Advanced Micro Devices X86-64
Version: 0x1
Entry point address: 0x1060
Start of program headers: 64 (bytes into file)
Start of section headers: 14976 (bytes into file)
Flags: 0x0
Size of this header: 64 (bytes)
Size of program headers: 56 (bytes)
Number of program headers: 14
Size of section headers: 64 (bytes)
Number of section headers: 32
Section header string table index: 31
- Use the command line to view : lscpu | grep -i byte
[email protected]:~/ws/thread_local$ lscpu | grep -i byte
Byte Order: Little Endian
- Use the code (union) Judge
#include <stdio.h>
union Endian {
char a;
int b;
};
int main(){
Endian endian;
endian.b = 1;
if (endian.a == 1) {
printf("little endian\n");
}else{
printf("big endian\n");
}
return 0;
}
[email protected]:~/ws$ ./main
little endian
Network order
Network transmission generally adopts large end sequence , Also known as network byte order , Or network sequence .IP The protocol defines the large end order as the network byte order .
边栏推荐
- Prevent others from using the browser to debug
- [hdu] p1466 calculate the number of intersections of straight lines
- Module 8 job
- E-R diagram
- Express framework installation and start service
- Wallys/DR7915-wifi6-MT7915-MT7975-2T2R-support-OpenWRT-802.11AX-supporting-MiniPCIe
- Debian10 create users, user groups, switch users
- [learning notes] roll back Mo team
- [hdu] P6964 I love counting
- On AI and its future trend | community essay solicitation
猜你喜欢

MySQL -- how to access the database of a computer in the same LAN (prenatal education level teaching)

Day367: valid complete square

SAP ui5 application development tutorial 103 - how to consume the trial version of the third-party library in SAP ui5 applications

SQL programming task02 job - basic query and sorting

SAP ui5 application development tutorial 102 - detailed explanation of the print function of SAP ui5 applications
Voice network multiplayer video recording and synthesis support offline re recording | Nuggets technology solicitation

B tree and b+ tree

魔王冷饭||#099 魔王说西游;老板的本质;再答中年危机;专业选择

A hundred lines of code to realize reliable delay queue based on redis

SAP ui5 application development tutorial 103 - how to consume third-party libraries in SAP ui5 applications
随机推荐
Autumn move script B
Voice network multiplayer video recording and synthesis support offline re recording | Nuggets technology solicitation
Analysis of current mainstream video coding technology | community essay solicitation
C. Diluc and Kaeya——Codeforces Round #724 (Div. 2)
SYSTEMd summary
Network module packaging
There is no corresponding change on the page after the code runs at the Chrome browser break point
Debian10 configuring rsyslog+loganalyzer log server
E-R diagram
Similar to attention NLP
The longest child sequence of the 2019 Blue Bridge Cup
On AI and its future trend | community essay solicitation
JS to read the picture of the clipboard
[learning notes] roll back Mo team
Prevent others from using the browser to debug
3DMAX modeling notes (I): introducing 3DMAX and creating the first model Hello World
SFOD:无源域适配升级优化,让检测模型更容易适应新数据
Time complexity
Debian10 create users, user groups, switch users
a++,++a,!,~