Jay S

Jay S

  • NA
  • 238
  • 36.3k

Using tilde (~) error

May 27 2013 2:35 PM
I have seen a portion of code that looks like this:

public static short ReadEncryptedShort2(int ReputationAddress)
{
int bits = ReputationAddress & 15;
ushort num = (ushort)MainProcess.ReadShort(ReputationAddress);
num = (ushort)MainProcess.rol_short((uint)num, bits);
num = ~num;
num = (ushort)MainProcess.rol_short((uint)num, 12);
num = ~num;
num = (ushort)MainProcess.rol_short((uint)num, bits);
return (short)num;
}

I've never seen the use of "~" before so am not sure how to debug.

I've googled the usage and its something to do with flipping the bytes(?)

The error i am getting it:

Cannot implicitly convert type 'int' to 'ushort'. An explicit conversion exists (are you missing a cast?)

can someone help point me in the right direction whats going on and why the error. Do i need some special reference/assembly to use the "~"?

Thanks,

Answers (1)