由买买提看人间百态

topics

全部话题 - 话题: endianess
(共0页)
O*******d
发帖数: 20343
1
来自主题: Programming版 - Intel为什么选用little endian? (转载)
这个世界上,光在转换endianess上花的能源就很多啊。 特别是在网络上, TCP/IP要
求用big endian,client需要把自己的endianess转换成big endian,到了server那一
端,还要把big endian转换成自己的endianess。
u****u
发帖数: 229
2
来自主题: JobHunting版 - 请问一个little endian 系统的问题
1) 移位操作和endianess没有一点关系.
2) unsigned int32 a=0x000000ff, unsigned int16 b=0x00ff.和endianess没有一点
关系.
3) 为什么我们说C语言不好?问题就是在于有太多的类似的概念不清的新手上来就用C.
O*******d
发帖数: 20343
3
给一个C语言的code,可以检查endianess
#include
int main(int argc, char** argv)
{
int a = 0xAABBCCDD;
unsigned char* p = (unsigned char*)&a;
if(p[0] == 0xAA)
printf("Is big endian\n");
else if(p[0] == 0xDD)
printf("Is little endian\n");
else
printf("unknonw endianess\n");
return 0;
}
Z****e
发帖数: 2999
4
来自主题: Java版 - byte[] to int[]
try ByteBuffer:
ByteBuffer buf = ByteBuffer.wrap(byteArray);
buf.order(endianess); //set endianess
IntBuffer intBuf = buf.asIntBuffer(); //check for null
int[] intArray = intBuf.array();

的转换如下:
g*********o
发帖数: 4653
5
这个新闻在一些当地小报上是题目这样报道的。
当奈特和汉奸老将不停指责别的国家独裁专政的时候,黑总统也开始更加独裁了哦
这怎么回事呢?
http://www.dispatch.com/content/stories/local/2012/01/05/obama-
SHAKER HEIGHTS, Ohio — Defying congressional Republicans, President Barack
Obama appointed Richard Cordray yesterday to head a new consumer-protection
agency.
The decision to install Cordray as director of the Consumer Financial
Protection Bureau without Senate approval rankled Republicans in part
because they say the U.S. Senate is not on recess. The U.S. Constituti... 阅读全帖
s********k
发帖数: 6180
6
来自主题: JobHunting版 - 请问一个little endian 系统的问题
Thanks,只有pointer的操作跟endianess有关系了?
Q*******e
发帖数: 939
7
来自主题: JobHunting版 - 一道C语言题
估计出题人的考点就是endianess
z*****n
发帖数: 7639
8
来自主题: Joke版 - 好挫的F家面经 (转载)
不知道endianess的程序员不要也罢。任何一门computer architecture
或者operating system 的课都要讲的东西。
z*****n
发帖数: 7639
9
来自主题: Joke版 - 好挫的F家面经 (转载)
我当年给人出的面试题就是用C或者C++写个程序,find out
the endianess of the system.
c***k
发帖数: 1589
10
稍微底层一点的开发就悲剧了,我上次遇见一个问题在模拟器上一点问题都没有,一旦
到了iPhone上就全坏了,后来发现iPhone和模拟器架构根本不一样,一个i386,一个
ARM,Endianess正好是反的
y***u
发帖数: 5243
11
; Endianess正好是反的
你这是瞎说了啊。。。都是little endian
c***k
发帖数: 1589
12
真的吗,那我下次把code片段发上来,我是手动做了endianess的转换。
j*******e
发帖数: 674
13
什么叫“成功连接”?UDP本身是无连接的。
是不是你自己在UDP上有自己的应用层协议?你自己的应用层协议“成功链接”?
在ARM9 debian 里tcpdump能看到收到UDP packet? debian里有防火墙之类吗?
另外很有可能你的ARM设成big endian,你的服务器端没有做endianess转换。
d****i
发帖数: 4809
14
这玩意儿好用吗?我的都是自己写序列化/反序列化的代码,稍微麻烦些,尤其要处理
不同的字长和endianess。
d****i
发帖数: 4809
15
Using a file to convert back and forth is a waste. You can simply use a
pointer to your struct data to do the transfer. But bear in mind that the
way you wrote may cause issue mainly due to two reasons:
1. Compiler can do some padding to struct
2. Endianess issue (big/little endian)
So in order to make it correct during network transmission, you first want
to make sure that compiler padding is removed, so you can use #pramga
directive:
#pragma pack(1)
struct packed_struct {
unsigned int f1:8... 阅读全帖
r*****8
发帖数: 2560
16
ADBC,非常感谢指点。
实际数据中有很多跨字节、破字节的数值,字节序(endianess)的问题我已
经遇到了。还好我们的数据不是向公众传递,自己内部几台机器做相应的调整就好了。
“You can simply use a pointer to your struct data to do the transfer.”
我总觉得存盘的步骤可以省略。可是我试了几次都不行,劳驾您再说清楚一些。我
试了这个,编译通不过:
char * char_pointer;
char_pointer = &packed_data;
指针怎么用,我不太懂。

即使忽略警告,我怎么读指针的每一位的内容?
char_pointer+1
char_pointer+2
里面的内容怎么读出来?
(共0页)