Page 1 of 1

[resolved] long long

Posted: Thu Sep 18, 2003 2:06 am
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;

Posted: Thu Sep 18, 2003 5:54 am
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.

Posted: Thu Sep 18, 2003 7:01 am
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.)

Posted: Sat Sep 20, 2003 3:46 am
by bugzpodder
thanks a bunch you guys!!