当前位置:网站首页>Byte order problem
Byte order problem
2022-06-26 01:52:00 【Look back in vain】
Where there is network transmission, there is a byte order problem , The problem of byte count mainly exists in multi byte types Single byte has no byte order problem . Why can different memory have different storage methods , There are two mainstream Big end (big endian) And little end .
At the big end The high order of a value has the status of an address for example 0x16 78 stay int a This is how you keep it 16 78
The small end The low order of a value has the status of an address for example 0x16 78 stay int a Zhongshi village 78 16
remember Byte order only applies to multibyte , for example int long type Yes char Type has no function in network transmission and does not need to be switched .
But remember, union There may be an exception multibyte Terry in .
union test {
struct test_a {
char a :3;
char b: 5;
};
char d;
}test_t;
In this union Variable test_t in Because it's all char We can't even transmit use htoas htoal It's no use going around But its region is a Multi byte has byte order problem
for example our This is the case during transmission test_t.d=0b0110 1000
In the big end We can get test_t.a == 011, test_t.b=0100; Don't understand bit Whole upside down I thought so 00010110 It's wrong.
And in the small end test_t.a=000, test_t.b=01101
Be careful The reverse order of oneself is In bytes Immortal bit So the top 3 bit and 5 bit In their units It's not Whole bit Reverse
边栏推荐
- Exploring temporary information for dynamic network embedding
- 浅谈接口测试(一)
- Interpretation of script corresponding to postman assertion
- recvmsg & sendmsg
- How to add a "security lock" to the mobile office of government and enterprises?
- JQ获取对象的几种方式
- Postman斷言對應脚本的解釋
- GUN make (7) 执行make
- Distributed systems (II) understanding of distributed transactions
- Focal loss
猜你喜欢

Abnova丨ACTN4 DNA 探针解决方案

23. histogram equalization

通俗易懂C语言关键字static

Postman断言对应脚本的解释

蒟蒻初学单片机的一丢丢笔记

Talking about interface test (2)

Postman斷言對應脚本的解釋

One stop solution EMQ for hundreds of millions of communication of Internet of things

Cross validation -- a story that cannot be explained clearly

Interpretation of script corresponding to postman assertion
随机推荐
How to add a "security lock" to the mobile office of government and enterprises?
Abnova丨抗GBA单克隆抗体解决方案
web测试
前置++,后置++与前置--与后置--(++a,a++与--a,a--)
Show spirit chenzitong was invited to be the chief experience officer of the global finals of the sixth season perfect children's model
tos cos dscp 区别和作用
Test questions and answers for the 2022 baby sitter (Level 5) examination
Summary of xlnet model
Worthington胶原蛋白酶的多类型研究
APP测试(一)
GUN make (4) 规则的命令
Redis的使用
PTA class a simulated ninth bullet: 1114-1117
PTA class a simulated second bullet: 1136-1139
GUN make (3) Makefile的规则
GUN make (5) makefile中的变量
CYCA少儿形体礼仪 乐清市培训成果考核圆满落幕
APP测试与WEB测试的区别
Cross validation -- a story that cannot be explained clearly
Dataframe to list