Variable(int) bits....

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

Moderator: Board moderators

Post Reply
Heartattack!
New poster
Posts: 45
Joined: Fri Jan 16, 2004 7:02 pm
Location: CSE::BUET
Contact:

Variable(int) bits....

Post 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.
We will, We will BREAK LOOP!!!!
misof
A great helper
Posts: 430
Joined: Wed Jun 09, 2004 1:31 pm

Post 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
Heartattack!
New poster
Posts: 45
Joined: Fri Jan 16, 2004 7:02 pm
Location: CSE::BUET
Contact:

Post 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? :-?
We will, We will BREAK LOOP!!!!
abishek
Experienced poster
Posts: 131
Joined: Mon Dec 15, 2003 5:41 am

Post by abishek »

I use %lld for long long and %llu for unsigned long long
Heartattack!
New poster
Posts: 45
Joined: Fri Jan 16, 2004 7:02 pm
Location: CSE::BUET
Contact:

Post 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?
We will, We will BREAK LOOP!!!!
shamim
A great helper
Posts: 498
Joined: Mon Dec 30, 2002 10:10 am
Location: Bozeman, Montana, USA

Post 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]
Last edited by shamim on Mon Nov 29, 2004 6:53 am, edited 1 time in total.
Heartattack!
New poster
Posts: 45
Joined: Fri Jan 16, 2004 7:02 pm
Location: CSE::BUET
Contact:

Post by Heartattack! »

Thanks GURU bhai!. Ur awesome 8) 8) 8) 8)
We will, We will BREAK LOOP!!!!
Post Reply

Return to “C++”