Note that the number
76561197960265728 looks like a constant, but it really isn't.
This doesn't really matter if you're converting SteamId2 to SteamId64 because SteamId2 only supports individual user accounts. However, SteamId3 also contains the account type and (optionally) instance ID.
The correct calculation for Community IDs:
Code:
((universe << 56) | (accountType << 52) | (instance << 32) | accountId)
The first 3 default to 1 for individual user accounts, which means the "magic number" for individual accounts is
Code:
((1L << 56) | (1L << 52) | (1L << 32))
which is
76561197960265728.
(L is there because 64-bit literals need it in the language I was using to double check this.)
If you try this to get group profile IDs or game server profile IDs, it fails spectacularly because they use different account types and instances.
Side note: The second section of a SteamId2 is the lowest bit of the account ID and the third section is the remaining 31 bits of the account ID. Hence, to get the account ID, it's
((third section << 1) | second section)