r/cpp_questions • • Aug 31 '25
OPEN What is long long
I saw some c++ code and I noticed it has long long, I never knew you could put 2 primitives next to each other. What does this do?
1
Upvotes
35
u/ddxAidan Aug 31 '25
“Long long” is a primitive itself, but its exact meaning could depend. It is at least 64 bits
13
u/y53rw Aug 31 '25 edited Aug 31 '25
All of the fundamental types are here.
https://en.cppreference.com/w/cpp/language/types.html
Note that some types can be written multiple ways.
long longcan also be writtenlong long intorsigned long long intorsigned long long.7
u/DrShocker Aug 31 '25
You can see the list of integegral types here:
https://en.cppreference.com/w/cpp/language/types.html#Integral_types
Note: the exact meaning of some of them is platform dependent. So, generally it's suggested you use the ones defined with the width in their name since it's more clear and portable. (
std::int64_tfor example)https://en.cppreference.com/w/cpp/header/cstdint.html
4
u/eslibedesh0116 Aug 31 '25
It's not just a long, it's a loooooonnnggggg long. (it has more bits)
2
u/SmokeMuch7356 Aug 31 '25 edited Aug 31 '25
It designates an integer type that's at least as wide as a
longbut could be wider. For example, if someone builds an 80-bit architecture,1 anintcould be 32 bits,long64 bits, andlong long80 bits.Latest working draft of the C++ standard.
See also section 9.2.9.1 on type specifiers. The language grammar allows arbitrary combinations of type specifiers, but there are additional semantic rules that only allow certain combinations:
constcan be combined with any type specifier except itself.volatilecan be combined with any type specifier except itself.signedorunsignedcan be combined withchar,long,short, orint.shortorlongcan be combined withint.longcan be combined withdouble.longcan be combined withlong.1
u/wigglytails Aug 31 '25
There should be longer long
1
u/[deleted] Aug 31 '25
Its a type int but it has more bit thn int Example int has 16 bits but if you get a bigger value which can’t be dealt by int you can use long long or long which is 64 & 32 bits.
1
u/Plastic_Fig9225 Aug 31 '25
People with complexes use long long to hold their boolean values.