64位整数 [英] 64 bit integer
问题描述
您好,我相信这有一个快速简便的解决方案,但我找不到
吧。
我需要存储19' '9'是一个整数,这意味着我需要一个无符号的64
位
整数。
在Visual Studio中的代码如下:
__int64 test = 9999999999999999999;
我使用g ++版本3.3.5(suse 9.3)并尝试过两种方法:
unsigned long long test = 999999999999999999;
和:
uint64_t test = 9999999999999999999;
两者都使用命令g ++ test.cpp进行编译错误
test.cpp:5:错误:整数常量对于long而言太大了类型
我打算包含一些或不通过g ++的选项,或者
有另一种方法可以做64位整数存储?
感谢您的帮助
>
Jay写道:您好,我确信这有一个快速简便的解决方案,但我找不到
它。
我需要以整数存储19''9',这意味着我需要一个无符号的64位整数。在Visual Studio中,代码为:
__int64 test = 9999999999999999999;
双下划线是赠品,这不是C ++,而是一个
Microsoft
扩展名。
我使用g ++版本3.3.5(suse 9.3)并尝试过两种方法:
unsigned long long test = 999999999999999999;
和:
uint64_t test = 9999999999999999999;
使用命令g ++ test.cpp进行编译错误测试错误:5:错误:整数常量对于long而言太大了type
合理的,按照标准规则它可能确实拒绝代码。如果
你需要GCC扩展到C ++,你应该在GCC小组中询问。
HTH,
Michiel Salters
Jay写道:您好,我确信这有一个快速简便的解决方案,但我找不到
它。
我需要存储19''9'的整数,这意味着我需要一个无符号的64位整数。
[snip]
或者你可以使用任意精度的数字类。各种内置整数类型的大小取决于平台,因此你需要查看你的操作系统/编译器文档。
干杯! --M
所以没有使用扩展名就没有办法在C ++中这样做吗?
如果这是错误的这个问题的小组,你碰巧知道
哪个群体更合适?
谢谢
Hello, I am sure this has a quick and easy solution but I can''t find
it.
I need to store 19 ''9''s in an integer which means i need an unsigned 64
bit
integer.
in Visual Studio the code would be:
__int64 test = 9999999999999999999;
I am using g++ version 3.3.5(suse 9.3) and have tried both:
unsigned long long test = 999999999999999999;
and:
uint64_t test = 9999999999999999999;
both have this compile error using the command "g++ test.cpp"
test.cpp:5: error: integer constant is too large for "long" type
Am I forgeting to include something or not passing an option to g++, or
is
there another way to do 64 bit integer storage?
Thank you for your help
Jay wrote:Hello, I am sure this has a quick and easy solution but I can''t find
it.
I need to store 19 ''9''s in an integer which means i need an unsigned 64
bit integer. in Visual Studio the code would be:
__int64 test = 9999999999999999999;
The double underscore is a giveaway that this isn''t C++, but a
Microsoft
extension.
I am using g++ version 3.3.5(suse 9.3) and have tried both:
unsigned long long test = 999999999999999999;
and:
uint64_t test = 9999999999999999999;
both have this compile error using the command "g++ test.cpp"
test.cpp:5: error: integer constant is too large for "long" type
Reasonable, by the standard rules it may indeed reject the code. If
you need an GCC extension to C++, you should ask in a GCC group.
HTH,
Michiel Salters
Jay wrote:Hello, I am sure this has a quick and easy solution but I can''t find
it.
I need to store 19 ''9''s in an integer which means i need an unsigned 64
bit
integer.
[snip]
Or you could use a number class with arbitrary precision. The sizes of
the various built-in integral types are platform-dependent, so you''ll
want to check with your OS/compiler documentation.
Cheers! --M
So is there no way to do this in C++ without using an extension?
If this is the wrong group for this question, do you happen to know
which group would be more appropriate?
Thank you
这篇关于64位整数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!