William M. answered 12/14/19
Game Programming & Animation (Unreal, Blender) | Comp Sci Tutor & Math
First of all, you have to realize that these are just bits stored in the computer, and they are INTERPRETED however you say it should be...
In the below example, I took your example (-123123123), and stored it in an unsigned long long variable foo.
Then, when I tried to print it out, it was interpreted as an unsigned long long (18446744073586428493), which is the exact same bit pattern as that for -123123123.
To see that, I printed it out again using a variety of printf modifiers.
(see the following reference page... http://www.cplusplus.com/reference/cstdio/printf/)
#include <stdio.h>
int main(int argc, const char* argv[]) {
// converting your -123123123 to unsigned long long
unsigned long long foo = (unsigned long long)-123123123;
unsigned long bar = (unsigned long)-123123123; // converting your -123123123 to unsigned long
printf("%llu\n", foo); // unsigned long long (have to put the ll first, then u for unsigned long long)
printf("%zu\n", bar); // unsigned long (have to put z first, then u for unsigned long)
printf("%ld\n", bar); // signed long (have to put l first, then d for signed long)
printf("%d\n", (int)bar); // signed int (or just say d, for signed int)
return 0;
}
//---------------------------------- OUTPUT ------------------------
18446744073586428493
18446744073586428493
-123123123
-123123123
4171844173
Program ended with exit code: 0
Hope that helps.