~ Question.
#1

Hello, i saw that it's possible to use ~ infront of variables.

What does it actually do, how it actually works?

I know ! means the oposite of true.

pawn Код:
if(~pData[p][TrailerCreated])
        return Send(p,-1, "Trailer is not created!");
The code above does not work.
Reply
#2

Well it apparently means ones complement of. I'm not too familiar with that kind of stuff but maybe you are.
In the PAWN-LANG document the description is:

Bit Manipulation:

~e
results in the one’s complement of e.


Found this on wikipedia, might give a good description:
http://en.wikipedia.org/wiki/Signed_....27_complement


Good luck!
Reply
#3

Thanks for that, i didn't udnerstand enything.

but i ran some tests...
Strange :O

pawn Код:
new e;
printf("%d",~e+~10);
Result: -12
printf("%d",~e*3);
Result:-3
printf("%d",~e*~3);
Result:4
No idea...
Reply
#4

I saw ****** using '~', I'm sure he will post what does it mean.
Reply
#5

here is my quick test
pawn Код:
printf("%d",~1);
result:-2
    printf("%d",~2);
result:-3
    printf("%d",~3);
result:-4
    printf("%d",~4);
result:-5
    printf("%d",~5);
result:-6
    printf("%d",~10);
result:-11
    printf("%d",~100);
result:-101
    printf("%d",~1000);
result:-1001
    printf("%d",~10000);
result:-10001
    printf("%d",~100000);
result:-100001
and reading up about it it takes the binary number and inverts the bits (ie 1010101 would become 0101010)
and then adds one

its seems to be a way or storing negitive numbers in binary
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)