I want to Change a Char to the short with the same bit structure.
Both are 16 bits
I understand that short are 2s complement if they were 1s complement I could use
if a < 0 {return (short) math.abs a + 2 ^ 15;} else {return (short) a;} //right?
How do I do this to 2s complement negative?
I simply want to be able to manipulate the innards of a Char in the same way as I can a Integer.
If the answer is just add one I am going to become emotional 🙂
The simple solution is to do
Perhaps you imagine it has to be more complicated than it is 😉
In that case you don’t even want a
short, you want anintwhich is even simpler.e.g.
No, even less than that. :j
BTW you can do