为什么的地址号码不等于在分解和十六进制? [英] Why the address number is not equal in dec and in hex?

查看:118
本文介绍了为什么的地址号码不等于在分解和十六进制?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

debian@debian:~$ cat  /tmp/test.c
#include<stdio.h> 
int  main(void)
{
 int m=1;
 printf("m=%d\n",&m);
 printf("m=%p\n",&m);
}
debian@debian:~$ gcc  /tmp/test.c -o  /tmp/test.exe
debian@debian:~$ /tmp/test.exe
m=-1078061268
m=0xbfbe172c
debian@debian:~$ python
Python 2.7.3 (default, Jan  2 2013, 16:53:07) 
[GCC 4.7.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> print hex(-1078061268)
-0x4041e8d4

为什么 -1078061268 处于DEC不是 0xbfbe172c 十六进制等于?

why the -1078061268 in dec is not equal 0xbfbe172c in hex?

推荐答案

他们是一样的,你要比较签署无符号。

They are the same, you're comparing signed to unsigned.

看看这里的格式。

#include<stdio.h> 
int  main(void)
{
   int m=1;
   printf("m=%u\n",&m);  // 3219008780
   printf("m=%p\n",&m);  // 0xbfde2d0c
}

这篇关于为什么的地址号码不等于在分解和十六进制?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆