Long Long doesn't support

Write here if you have problems with your C++ source code

Moderator: Board moderators

Post Reply
TISARKER
Learning poster
Posts: 88
Joined: Tue Oct 12, 2004 6:45 pm
Location: Bangladesh
Contact:

Long Long doesn't support

Post by TISARKER »

#include<stdio.h>
void main()
{
long long a;
a=4000000000;//400 core
printf("%lld\n",a);
}

the above code does not works properly.When it is over 2147483647 then
it gives elligal result.

whats the reson.Who can help me.
Thanks.
Mr. Arithmetic logic Unit
Krzysztof Duleba
Guru
Posts: 584
Joined: Thu Jun 19, 2003 3:48 am
Location: Sanok, Poland
Contact:

Post by Krzysztof Duleba »

Try a=4000000000LL;
backslash null
New poster
Posts: 8
Joined: Tue Nov 11, 2003 11:02 pm

Post by backslash null »

Hi,
u can alsso use type cast like this:
a=(long long) 4000000000;
printf("%lld",a);
CDiMa
Experienced poster
Posts: 214
Joined: Fri Oct 17, 2003 5:49 pm
Location: Genova

Post by CDiMa »

backslash null wrote:Hi,
u can alsso use type cast like this:
a=(long long) 4000000000;
printf("%lld",a);
This shoudn't be done, since you are casting an integer constant to a long long variable.
Depending on the compiler this may or may not work as expected.
To be safe it's better to specify with LL that your constant is of long long type.

Ciao!!!

Claudio
Post Reply

Return to “C++”