Created
June 27, 2021 18:34
-
-
Save TheSithPadawan/4f6430dbf1c527f23f0f15af7f51c4a2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// long and long int are identical | |
// int is optional | |
// long is a signed type size of long in c++: at least 32 bits | |
long x; | |
long int x; | |
// long long is a signed type of at least 64 bits | |
long long int x; | |
long long; | |
// problem with following code when c is really large | |
int i = 0; | |
int j = sqrt(c); | |
// runtime error | |
long res = i*i + j*j; // signed integer overflow because i*i + j*j is still treated as int type | |
// no runtime error by performing type cast | |
long res = (long) i*i + j*j; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment