Page 1 of 1

Variable(int) bits....

Posted: Thu Nov 25, 2004 3:00 pm
by Heartattack!
Could someone tell me the number of bits for the following variables (in the case of the online judge, obviously):

1.int (16 or 32)
2. long
3. long long

The reason I ask is that many problems say stuff like "input will be less than or equal to 32767" and in other cases "the result will fit into an integer" or "the result will be less than 2^31-1". In VC++ ints and longs are 32 bits. Is it the same with the online judge's compiler?

Any help is appreciated.

Posted: Thu Nov 25, 2004 4:04 pm
by misof
int, long: 32 bit signed, i.e. -2^31 to 2^31 -1
long long: 64 bit signed, i.e. -2^63 to 2^63 -1

Posted: Fri Nov 26, 2004 8:38 am
by Heartattack!
Thanks. BTW, how do I use long long? I think it's 10LL and %Ld. Is that right? It doesn't work in VC++. VC++ has _int64 for the 64 bit integer. But that won't work with the OJ, will it? :-?

Posted: Fri Nov 26, 2004 11:21 am
by abishek
I use %lld for long long and %llu for unsigned long long

Posted: Sat Nov 27, 2004 8:19 pm
by Heartattack!
What can I use with VC++?
Declaring long long gives a 64bit int. Using cin/cout gives proper results. But I can't get printf() to work right in VC++. Any tips?

Posted: Sun Nov 28, 2004 8:05 am
by shamim
Heartattack! wrote: What can I use with VC++?
Declaring long long gives a 64bit int. Using cin/cout gives proper results. But I can't get printf() to work right in VC++. Any tips?
The following should work:

[cpp] printf("%I64d",long_num); // __int64
printf("%I64u",unsigned_long_num); // for unsigned __int64
[/cpp]

Posted: Sun Nov 28, 2004 7:10 pm
by Heartattack!
Thanks GURU bhai!. Ur awesome 8) 8) 8) 8)