[resolved] long long

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

Moderator: Board moderators

Post Reply
bugzpodder
Experienced poster
Posts: 147
Joined: Fri Jun 13, 2003 10:46 pm

[resolved] long long

Post by bugzpodder »

hmm well i have a variable long long and i want to assign some big numbers to it. something like:

v=a*a*a;

i know that the value definately fits in long long v, but it is bigger than a standard integer. this has occured to me on a number of occasions :(
it wont even let me use something like v=10000000000000;
Last edited by bugzpodder on Sat Sep 20, 2003 3:46 am, edited 1 time in total.
UFP2161
A great helper
Posts: 277
Joined: Mon Jul 21, 2003 7:49 pm
Contact:

Post by UFP2161 »

If "a" is not of the "long long" type, you need to explicitly cast it. Else, it'll do the arithmetic using that type, and then convert to "long long" when done.
Per
A great helper
Posts: 429
Joined: Fri Nov 29, 2002 11:27 pm
Location: Sweden

Post by Per »

And if you want to do an assignment of an explicit number, you can write v = 12345LL; (or 12345ULL if the number is >= 2^63).

(But of course, if the number is small enough to fit in an int, you don't need the LL suffix as the number, having been parsed correctly as an int, will be promoted to long long anyway.)
bugzpodder
Experienced poster
Posts: 147
Joined: Fri Jun 13, 2003 10:46 pm

Post by bugzpodder »

thanks a bunch you guys!!
Post Reply

Return to “C++”