signed long long value = -2147483648;
cout << ((signed long long)value);
outputs 2147483648 (no minus sign), why?
www.geeksforgeeks.org/advanced-c-boost-library/amp/ There is a rule by which you can calculate how many digit a data type can store and the logic is 2^10 = 10^3 (nearly) i.e as long long int is an 64 bit integer, it can support 18 digit number because 2^64 = 10^18(nearly) by the above rule.
The answer is yes, but you don't need unsigned long long , unsigned long would be enough. A 32 bit number can represent over 4 * 10^9.
INT_MIN specifies that an integer variable cannot store any value below this limit. Values of INT_MAX and INT_MIN may vary from compiler to compiler. Following are typical values in a compiler where integers are stored using 32 bits. Value of INT_MAX is +2147483647. Value of INT_MIN is -2147483648.
signed long long value = -2147483648;
2147483648
cannot be represented in a 32-bit signed integer, so it is converted to an unsigned, then unary minus is applied (which doesn't change anything), and then it is assigned to the signed long long. Use -2147483648LL
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With