• Welcome to Valhalla Legends Archive.
 

u_long

Started by MoNksBaNe_Agahnim, March 26, 2004, 01:35 PM

Previous topic - Next topic

MoNksBaNe_Agahnim

I have seen this before as a reserved word, mainly in bnet bots...

example
u_long u_flags

What is u_long exactly defining the variable u_flags as?

K

Quote from: MoNksBaNe_Agahnim on March 26, 2004, 01:35 PM
I have seen this before as a reserved word, mainly in bnet bots...

example
u_long u_flags

What is u_long exactly defining the variable u_flags as?

probably

typedef unsigned long u_long;

iago

I would assume it's unsigned long.
This'll make an interesting test for broken AV:
QuoteX5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*


MoNksBaNe_Agahnim

what exactly does unsigned/signed mean?

Adron

#4
Quote from: MoNksBaNe_Agahnim on March 27, 2004, 12:22 PM
what exactly does unsigned/signed mean?

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.


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



Maddox

#5
Signed integers are represented by two's complement. That is the inversion of the bits + 1.

For example
unsigned int a = 96;
printf("%d %d\n", a, ~a + 1);

Outputs: 96 -96
asdf.

MrRaza

what does the '~' do?

Yoni

~ is bitwise NOT - it complements each bit in the parameter. (0 becomes 1, 1 becomes 0.)