Author | Message | Time |
---|---|---|
MoNksBaNe_Agahnim | I have seen this before as a reserved word, mainly in bnet bots... example [code]u_long u_flags[/code] What is u_long exactly defining the variable u_flags as? | March 26, 2004, 7:35 PM |
K | [quote author=MoNksBaNe_Agahnim link=board=30;threadid=6007;start=0#msg51862 date=1080329744] I have seen this before as a reserved word, mainly in bnet bots... example [code]u_long u_flags[/code] What is u_long exactly defining the variable u_flags as? [/quote] probably [code] typedef unsigned long u_long; [/code] | March 26, 2004, 7:45 PM |
iago | I would assume it's unsigned long. | March 26, 2004, 7:46 PM |
MoNksBaNe_Agahnim | what exactly does unsigned/signed mean? | March 27, 2004, 6:22 PM |
Adron | [quote author=MoNksBaNe_Agahnim link=board=30;threadid=6007;start=0#msg52070 date=1080411728] what exactly does unsigned/signed mean? [/quote] An unsigned 32-bit integer uses 32 bits to represent the amount. It can take any integer value from 0 to 4294967295. A signed 32-bit integer uses 31 bits to represent the amount and 1 bit to represent the sign. It can take any integer value from -2147483648 to 2147483647. Example; 3-bit integer: The left-most bit is the sign in a signed integer, so all values where that bit is 1 are negative. [code] binary unsigned signed 000 0 0 001 1 1 010 2 2 011 3 3 100 4 -4 101 5 -3 110 6 -2 111 7 -1 [/code] | March 27, 2004, 6:37 PM |
Maddox | Signed integers are represented by two's complement. That is the inversion of the bits + 1. For example [code]unsigned int a = 96; printf("%d %d\n", a, ~a + 1);[/code] Outputs: 96 -96 | March 30, 2004, 2:55 AM |
MrRaza | what does the '~' do? | March 30, 2004, 7:00 AM |
Yoni | ~ is bitwise NOT - it complements each bit in the parameter. (0 becomes 1, 1 becomes 0.) | March 30, 2004, 7:07 AM |