I have tried searching the newsgroup along with the GCC site and could
not find what I think is probably a simple solution.
I am using a 64bit unsigned long long integer and can manipulate 64bits
within the variable but I cannot assign a 64bit constant to it.
With my simple test program:
int main()
{
unsigned long long test;
test = 18446744073709551606;
test = 0xFFFFFFFFFFFFFFF6;
}
I get the following errors with gcc v3.3.x and 3.4:
test.cpp:7: warning: this decimal constant is unsigned only in ISO C90
test.cpp:7: error: integer constant is too large for "long" type
test.cpp:8: error: integer constant is too large for "long" type
I have also tried using variations with no success:
test = (unsigned long long)18446744073709551606;
There must be a way to do this, and it is probably just something
simple that I am overlooking. Can anyone help?
Thanks. 7 17005
Jeff Gilchrist wrote: test = 18446744073709551606; test = 0xFFFFFFFFFFFFFFF6;
Add the suffix "LLU" to the constants and it should work for you.
-- John
Jeff Gilchrist wrote: I have tried searching the newsgroup along with the GCC site and could not find what I think is probably a simple solution.
I am using a 64bit unsigned long long integer and can manipulate 64bits within the variable but I cannot assign a 64bit constant to it.
With my simple test program:
int main() { unsigned long long test;
There is no 'long long' data type in C++. There is in C99. Perhaps you
need to post your question to the C newsgroup (comp.lang.c)?
test = 18446744073709551606; test = 0xFFFFFFFFFFFFFFF6; }
I get the following errors with gcc v3.3.x and 3.4:
test.cpp:7: warning: this decimal constant is unsigned only in ISO C90
The constant has a signed type _unless_ it has the U suffix. Try
test = 18446744073709551606U; // for "native" unsigned int
or
test = 18446744073709551606UL; // for "native" unsigned long
The constant is really too big to fit into a signed integer.
test.cpp:7: error: integer constant is too large for "long" type test.cpp:8: error: integer constant is too large for "long" type
I have also tried using variations with no success: test = (unsigned long long)18446744073709551606;
There must be a way to do this, and it is probably just something simple that I am overlooking. Can anyone help?
If your _C++_ compiler natively supports 64-bit numbers, then it would be
under 'unsigned long' type, and not 'unsigned long long'. Otherwise, this
is a wrong forum to ask about it. Try gnu.g++.help.
Victor
Victor Bazarov wrote: There is no 'long long' data type in C++. There is in C99. Perhaps you need to post your question to the C newsgroup (comp.lang.c)?
You are right of course. I sometimes forget which things are in the C
standard and which are in the C++ since most C++ compilers treat C code
as a substet of C++ and its hard to tell the difference.
For people with 32bit processors, how does one create a 64bit data type
in C++ if 'int' and 'long' are both treated as 32bit in the
compiler(s)?
Thanks,
Jeff.
John Valko wrote: Add the suffix "LLU" to the constants and it should work for you.
Thanks John, works like a charm.
Much appreciated,
Jeff.
Jeff Gilchrist wrote: [..] For people with 32bit processors, how does one create a 64bit data type in C++ if 'int' and 'long' are both treated as 32bit in the compiler(s)?
Usually that's achieved by means of some language extensions. E.g., VC++
has '__int64' and 'unsigned __int64' that can be used. Constants of these
types have non-standard suffixes 'i64' and 'ui64'.
V
Victor Bazarov wrote: Jeff Gilchrist wrote: [..] For people with 32bit processors, how does one create a 64bit data type in C++ if 'int' and 'long' are both treated as 32bit in the compiler(s)? Usually that's achieved by means of some language extensions. E.g., VC++ has '__int64' and 'unsigned __int64' that can be used.
And gcc has 'long long' and 'unsigned long long'.
Constants of these types have non-standard suffixes 'i64' and 'ui64'.
What do you mean by "non-standard suffixes"?
Rolf Magnus wrote: Victor Bazarov wrote:
Jeff Gilchrist wrote:
[..] For people with 32bit processors, how does one create a 64bit data type in C++ if 'int' and 'long' are both treated as 32bit in the compiler(s)?
Usually that's achieved by means of some language extensions. E.g., VC++ has '__int64' and 'unsigned __int64' that can be used.
And gcc has 'long long' and 'unsigned long long'.
Constants of these types have non-standard suffixes 'i64' and 'ui64'.
What do you mean by "non-standard suffixes"?
AFAIK, there are no standard suffixes 'i64' and 'ui64'. There are 'L',
'U', 'UL', 'F'. And by "constants" I actually meant "literals". My bad. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Christian McArdle |
last post by:
REQUEST FOR DISCUSSION (RFD)
unmoderated group comp.os.ms-windows.programmer.64bit
This is a formal Request For Discussion (RFD) to create...
|
by: SysSpider |
last post by:
Hi again,
This is my problem: when i try to compile the code that contains the
function below, i get this:
--
gcc:21: error: case label does...
|
by: fctk |
last post by:
hello,
i'm trying to compile this small program:
int main(void) {
unsigned long int max;
max = 4000000000;
|
by: yxq |
last post by:
Hello,
The File.Delete(VS2005) function can not delete file on Vista-64bit, why?
And, what changes of API between 32-bit and 64-bit?
Thank you
|
by: Thomas Kehl |
last post by:
Hello.
I use the fallowing Functions to send Message from one Application to
another. This is working correct on a 32bit System. But on a 64Bit...
|
by: matevzb |
last post by:
I've ran into some fishy code that, at first glance, is buggy, but it
seems to work correctly
and none of the compilers I've tried (five so far, on...
|
by: cman |
last post by:
Hi guys, why does this fail raising bad_alloc
int *v = new int ;
if this succeeds
int *v = (int *) malloc((unsigned)6000000000)
both on the...
|
by: M O J O |
last post by:
(I'm using Visual Studio 2008)
I want my new develloper pc to be Vista 64bit, but all my clients are so
far 32bit (XP), so my questions are:
...
|
by: yxq |
last post by:
Hello,
The code below can popup the property dialog of a file, it works well on XP,
Vista 32bit, but it will not work on Vista 64bit, how to...
|
by: Kemmylinns12 |
last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
|
by: Naresh1 |
last post by:
What is WebLogic Admin Training?
WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
|
by: jalbright99669 |
last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
|
by: AndyPSV |
last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...
|
by: WisdomUfot |
last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific...
|
by: Matthew3360 |
last post by:
Hi,
I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web...
|
by: Oralloy |
last post by:
Hello Folks,
I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA.
My problem (spelled failure) is with the...
|
by: BLUEPANDA |
last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS...
|
by: Rahul1995seven |
last post by:
Introduction:
In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python...
| |