I’m writing code for a primality testing function that handles long long int’s.Do I have to use special operators for such large numbers?Is there any documentation concerning large number manipulation in C?I’m using the gnu standard library.Thanks.
I’m writing code for a primality testing function that handles long long int’s.Do I
Share
long long is new in C99, though many compilers have supported that as an extension before that.
With gcc a long long is 64 bits, you can use it like any other integer type, nothing special is required.
There’s a couple of things to be aware of though, integer constants in the source code needs the LL suffix (or LLU if it’s unsigned, e.g. you have to do
and not
Similarly, for outputting a long long with the printf family, you have to use the conversion specifier “%lld” instead of “%d” or “%ld” (or “%llu” if it’s unsigned), e.g.
There’s some docs about long long in gcc here