"long long" type initialization

T

thomas

Hi,

When I compile the source code with the initialization "long long
p = 1<<60;", an error says that it's not valid.
But I think that "long long" is 64 bits, so "1<<60" certainly
can be hold by "p".
Any suggestions?

Thomas.
 
I

Ian Collins

thomas said:
Hi,

When I compile the source code with the initialization "long long
p = 1<<60;", an error says that it's not valid.
But I think that "long long" is 64 bits, so "1<<60" certainly
can be hold by "p".
Any suggestions?

Does your compiler support long long? It is part of C, but not yet
standardised into C++.
 
I

Ian Collins

Ian said:
Does your compiler support long long? It is part of C, but not yet
standardised into C++.

Even if long long is supported, the compiler is probably objecting to
shifting 1 (which is an int) by more than the number of bits in an int.

try 1LL << 60
 
T

thomas

Even if long long is supported, the compiler is probably objecting to
shifting 1 (which is an int) by more than the number of bits in an int.

try 1LL << 60

Yeah, actually it causes a warning. And it prints "0" for the actual
value when running.
But the "1LL<<60" works well. Thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,599
Members
45,175
Latest member
Vinay Kumar_ Nevatia
Top