I cannot find an exact specification of how the value is intconverted to unsigned long longin the standard. Various similar transformations will be defined, such as int โ unsigned, unsigned โ int (UB if negative), unsigned long long โ int, etc.
int
unsigned long long
For example, GCC is -1converted to 0xffffffffffffffff, not to 0x00000000ffffffff. Can I rely on this behavior?
-1
0xffffffffffffffff
0x00000000ffffffff
, , max unsigned long long + 1 -1, max unsigned long long. ++ 4.7 , :
max unsigned long long + 1
max unsigned long long
4.7
, ( 2 , ). [. ( ). -end note]
, C99, C99 , 6.3.1.3 Signed :
6.3.1.3
, , , . 49)
49 :
49
, .
, :
++ 11 ยง 4.7 [conv.integral]/2 :
, ( 2 , ).
, -1 ( 2 sizeof(unsigned long long)), unsigned long long.
sizeof(unsigned long long)
. , int v unsigned long u , u= K * 2 n + v, K - 0, 1, n - unsigned long. , v , 2 n.
unsigned long
2 ++ , . n 2 n. ( std::numeric_limits ).
std::numeric_limits
, , , , -, undefined, unsigned . , , Visual ++ . , , , ( ) .
Source: https://habr.com/ru/post/1529678/More articles:Divide the line above to the line below - performanceSKTexture preload - iosAttributeError: 'module' object does not have attribute '[x]' - pythonHow to align subtitle text on the right in a carousel bootstrap? - htmlThe error handling table generated by the os.time () command Lua - datecreate table list in jquery - javascriptSetting inheritance field java vs constructor - javatesseract (v3.03) PDF output - linuxUse System.Net.Sockets in PCL (.Net 4.5 + phone 8) - c #How to get the actual path to the directory junction folder? - windows-7All Articles