1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
-
|
|
|
|
|
|
-
!
|
|
-
!
|
|
|
!
| #include <stdio.h>
#include <limits.h>
#include <string.h>
int main()
{
unsigned int ul1 = 0;
unsigned int ul2 = 0;
memset(&ul1, 0xFF, sizeof(ul1));
memset(&ul2, 0xFF, sizeof(ul2));
printf("%u(%ld)\n%u(%ld)\n\n", ul1, sizeof(ul1), ul2, sizeof(ul2));
const unsigned long long ull1 = ul1 + ul2;
printf("%llu(%ld)\n", ull1, sizeof(ull1));
const unsigned long long ull2 = static_cast<unsigned long long>(ul1) + ul2;
printf("%llu(%ld)\n", ull2, sizeof(ull2));
return 0;
}
|