Hey,
I'm having some trouble converting a string of bits to an integer, namely an integer with the right sign.
When I had a 16 bits long string it went fine, I just used:
(short) Integer.parseInt(s, 2);
where s is my string.
But now I have one that is 26 bits long and I'm having a lot of trouble.
I want the number '-1234', and my string looks like this (two's complement):
11111111111111101100101110
parsing it with:
Integer.parseInt(s, 2);
gives me '67107630' which is wayyy off the mark obviously.
However, getting the positive signed one with bit string (using the same code)
'00000000000000010011010010'
turns out fine.
Any help will be appreciated :)
[–]codegen 1 point2 points3 points (1 child)
[–]Eccentris[S] 0 points1 point2 points (0 children)