unsigned long long

wenmx 2008-03-14 10:03:52
unsigned long long类型数据的size是8个byte,但是我在程序中发现用它定义的变量没法被赋予大于2**32-1的数据(应该最大是2**64-1),另外,用printf()输出的格式是什么?忘高手解答。
...全文
2040 9 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
coldiceangel 2009-06-02
  • 打赏
  • 举报
回复
good
[Quote=引用 4 楼 mymtom 的回复:]
C/C++ code

/*-
* file: longlong.c
* auth: mymtom
* date: 2008-08-19
*/

#include <sys/types.h>
#include <limits.h>

#include <stdio.h>

int
main(void)
{
long long a = 0x1111222233334444;
int64_t b = 0x1111222233334444;
long long c = 0x1111222233334444L;
int64_t d = 0x1111222233334444L;
long long e = 0x1111222233334444…
[/Quote]
shseven 2009-06-02
  • 打赏
  • 举报
回复
可以使用Win32 Simple Data Types的ULONGLONG(ULONGLONG 64-bit unsigned integer. )

例如:ULONGLONG a;
wenmx 2008-03-19
  • 打赏
  • 举报
回复
4楼的程序确实说明了问题,我也请教了师兄,确实如4楼的程序中描述的。
野男孩 2008-03-15
  • 打赏
  • 举报
回复
VC6为啥不能编译纯粹的C程序?!
visame 2008-03-15
  • 打赏
  • 举报
回复

3楼的“在VC环境中编写C语言程序”不够准确。
你这里的VC是指老掉牙的VC6吧!
VC本来就是用来编译C++的,能够编译纯粹的C程序吗?
VC2005可以使用unsigned long long int.
#include <iostream>
#include <limits>
using namespace std;

int main()
{
cout<<numeric_limits<unsigned long long int>::max()<<endl;
}
//OUTPUT
18446744073709551615
请按任意键继续. . .
mymtom 2008-03-14
  • 打赏
  • 举报
回复

/*-
* file: longlong.c
* auth: mymtom
* date: 2008-08-19
*/

#include <sys/types.h>
#include <limits.h>

#include <stdio.h>

int
main(void)
{
long long a = 0x1111222233334444;
int64_t b = 0x1111222233334444;
long long c = 0x1111222233334444L;
int64_t d = 0x1111222233334444L;
long long e = 0x1111222233334444LL;
int64_t f = 0x1111222233334444LL;

unsigned long long g = 0xffffffffffffffffLL;

(void)printf("a = %#llx\n", a);
(void)printf("b = %#llx\n", b);
(void)printf("c = %#llx\n", c);
(void)printf("d = %#llx\n", d);
(void)printf("e = %#llx\n", e);
(void)printf("f = %#llx\n", f);

(void)printf("g = %#llx\n", g);
(void)printf("g = %#llu\n", g);
(void)printf("ULLONG_MAX = %#llu\n", ULLONG_MAX);

return 0;
}

mymtom@freebsd$ ./longlong
a = 0x1111222233334444
b = 0x1111222233334444
c = 0x1111222233334444
d = 0x1111222233334444
e = 0x1111222233334444
f = 0x1111222233334444
g = 0xffffffffffffffff
g = 18446744073709551615
ULLONG_MAX = 18446744073709551615
mymtom@freebsd$ uname -mrsp
FreeBSD 6.2-RELEASE amd64 amd64
mymtom@freebsd$ gcc -v
Using built-in specs.
Configured with: FreeBSD/amd64 system compiler
Thread model: posix
gcc version 3.4.6 [FreeBSD] 20060305
YFY 2008-03-14
  • 打赏
  • 举报
回复
在VC环境中编写C语言程序,只能用__int64,不支持unsigned long long。

#include "stdafx.h"

#include<stdio.h>
int main()
{
__int64 i64Tmp;

i64Tmp = 999999999999;

printf("__int64:%I64u\n",i64Tmp);

return 0;
}
asmst 2008-03-14
  • 打赏
  • 举报
回复
应该不会出现你说的情况,你是怎么发现的?靠不正确的输出?
输出应该使用%lld(有符号数)或者%llu(无符号数),两个都是字母L,不是数字1。
qiuqiu173 2008-03-14
  • 打赏
  • 举报
回复
printf(“%ld”,A)试试

70,020

社区成员

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

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