编写一个程序,判断系统是big endian,还是little endian
2016-04-14 14:47
525 查看
// Endian_1.cpp : 定义控制台应用程序的入口点。 // #include "stdafx.h" #include <stdlib.h> #include <stdio.h> #include <iostream> using namespace std; int _tmain(int argc, _TCHAR* argv[]) { long ii = 0x123456; long *pp=ⅈ if(*pp==0x56){////低字节存放在低地址端,即是首地址 cout<<"system is little endian"<<endl; } else{ cout<<"system is big endian"<<endl; } long i = 0x123456; long *p = &i; if (*p==0x56) { printf("This is little endian system\n"); } else { printf("This is big endian system\n"); } system("pause"); return 0; } //system is big endian //This is big endian system //请按任意键继续. . .
JAVA字节序
BIG-ENDIAN、LITTLE-ENDIAN跟多字节类型的数据有关,比如int,short,long型,而对单字节数据byte却没有影响。BIG-ENDIAN就是低位字节排放在内存的高端,高位字节排放在内存的低端。而LITTLE-ENDIAN正好相反。
比如 int a = 0x05060708
在BIG-ENDIAN的情况下存放为:
字节号 0 1 2 3 高地址端(高端)
高字节 数据 05 06 07 08
在LITTLE-ENDIAN的情况下存放为:
字节号 0 1 2 3 高地址端(高端)
数据 08 07 06 05 高字节
相关文章推荐
- 在Javascript中处理字符串之big()方法的使用
- little endian和big endian的概念解释,判定与用途
- Big Faceless Java PDF 阅读器
- 大端模式和小端模式
- Big Data for BI - 数据采集常见关键字
- Big Data 文章
- 研究人员涉足关键问题:厌恶者倾向于厌恶吗?(Researchers take on crucial question: Are haters gonna hate ?)
- HDU 1018
- Big Event in HDU
- BigMap 在PHP中的应用
- uva 10012 - How Big Is It?
- A Journey from Data Warehousing to Big data Insights – What I learnt from Henry Ford, Albert Einstei
- Big Three+noncopyable
- Android倚天剑之Notification之江南style
- big data相关的技术文章
- Big Data Ingestion and streaming product introduction
- Big Table and Small Table Join strategy in Oracle
- Storing Big Data with HBase
- BIG O
- java之BigDecimal类