signed to unsigned. How does this work?
- From: "Robert Smith" <logjammin@xxxxxxxxx>
- Date: Wed, 23 May 2007 13:17:21 GMT
Why/How does this work?
I know that if I want to convert a signed byte (ie > 0x7F) to unsigned
number I can promote it to an integer, like this:
byte a = (byte)0xAB; // -85
int b = a & 0xFF; // 171
The bit pattern is 10101011 (0xAB)
If I AND it with 11111111 (0xFF)
The result is 10101011
ie. the same number! so why does this change the number to an unsigned
(positive) number?
.
- Follow-Ups:
- Prev by Date: Re: Class destructors
- Next by Date: Re: signed to unsigned. How does this work?
- Previous by thread: How to write Array of Object to a file?
- Next by thread: Re: signed to unsigned. How does this work?
- Index(es):