高低位转换为unsigned long long 的问题

bclife 2008-07-01 09:32:42
#include <stdio.h>

int main()
{
unsigned long long num;
unsigned int high = 0, low = 1111 ;

num = high ;
num = num<<32+low ;
printf("num is %llu\n", num) ;
}

为什么输出的是0呢
...全文
232 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
bclife 2008-07-01
  • 打赏
  • 举报
回复
可以了 多谢各位了
artman 2008-07-01
  • 打赏
  • 举报
回复
vc6

unsigned __int64 num;
unsigned long high = 20, low = 1111 ;

num = high ;
num = (num <<32)+low ;
printf("num is %I64u\n", num) ;
yyyapple 2008-07-01
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 bclife 的回复:]
那为什么这样还是输出 1111呢

#include <stdio.h>

int main()
{
unsigned long long num;
unsigned long high = 20, low = 1111 ;

num = high ;
num = (num < <32)+low ;
printf("num is %llu\n", num) ; //换成printf("num is %I64u\n", num) ; 试试
}
[/Quote]
king_water 2008-07-01
  • 打赏
  • 举报
回复
(num <<32)+low ;
bclife 2008-07-01
  • 打赏
  • 举报
回复
那为什么这样还是输出 1111呢

#include <stdio.h>

int main()
{
unsigned long long num;
unsigned long high = 20, low = 1111 ;

num = high ;
num = (num<<32)+low ;
printf("num is %llu\n", num) ;
}
yyyapple 2008-07-01
  • 打赏
  • 举报
回复
[Quote=引用楼主 bclife 的帖子:]
#include <stdio.h>

int main()
{
unsigned long long num;
unsigned int high = 0, low = 1111 ;

num = high ;
num = num < <32+low ; //+的运算优先级大于<<,先+后 <<
printf("num is %llu\n", num) ;
}

为什么输出的是0呢
[/Quote]
artman 2008-07-01
  • 打赏
  • 举报
回复
num = (num < <32)+low ;

69,336

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧