当前位置:网站首页>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
边栏推荐
- 26. histogram back projection
- GUN make (7) 执行make
- Wechat circle of friends test point
- 17.11 std::atomic续谈、std::async深入谈
- Sunshine boy chenhaotian was invited to be the spokesperson for the global finals of the sixth season perfect children's model
- 论文阅读 Exploring Temporal Information for Dynamic Network Embedding
- On the difference between strlen and sizeof
- recvmsg & sendmsg
- Android system startup security
- Perfdog
猜你喜欢

元气少女王钰洁 受邀担任第六季完美童模全球总决赛代言人

前置++,后置++与前置--与后置--(++a,a++与--a,a--)

关于strlen与sizeof的区别

Explication du script correspondant à l'assertion Postman

recv & send

How to add a "security lock" to the mobile office of government and enterprises?

Energetic girl wangyujie was invited to be the spokesperson for the global finals of the sixth season perfect children's model

21. Hoff circle transformation

分布式系统(二)分布式事务的理解

俏皮少女王艺璇 受邀担任第六季完美童模全球总决赛推广大使
随机推荐
The answer skills and examples of practical cases of the second construction company are full of essence
17.11 std:: atomic continuation, std:: async in-depth discussion
Show spirit chenzitong was invited to be the chief experience officer of the global finals of the sixth season perfect children's model
反向输出一个整数
Basic concepts of machine learning
Sunshine boy chenhaotian was invited to be the spokesperson for the global finals of the sixth season perfect children's model
GUN make (4) 规则的命令
Several methods of JQ obtaining objects
Worthington胶原蛋白酶的多类型研究
浅谈接口测试(二)
分布式系统(二)分布式事务的理解
秀场精灵陈梓桐 受邀担任第六季完美童模全球总决赛首席体验官
Can bus transceiver principle
Forgotten Jieba participle
求n乘阶之和
PTA class a simulated sixth bomb: 1156-1159
wifi 相关知识详解
二造实务案例答题技巧和举例汇总,满满都是精髓
蒟蒻初学单片机的一丢丢笔记
readv & writev