Paul Tomblin wrote:
>
> In a previous article, look-lid said:
> >On 10 Aug 2005 10:02:30 -0700, "Rajesh.Rapaka"
> ><> wrote or quoted :
> >>number should be encoded in 16-bit. using java I am reading it as 2
> >>eight bits A and B. Now I need to add these 2 bits in such a way that I
> >>get the correct value in an 8-bit space.
> >
> >I presume you mean adding modulo 256.
> >
> >
> >sum = ( a + b ) & 0xff;
>
> I think he's trying to put two 8 bit values together to make one 16 bit
> value, in which case he'd want
>
> sum = a << 8 | b;
At least that makes sense with his subject, assuming he got his hex to decimal
conversion wrong. (8 << 8 |

is 0x88 or 136 decimal ... not 137 decimal.
--
Lee Fesperman, FFE Software, Inc. (
http://www.firstsql.com)
================================================== ============
* The Ultimate DBMS is here!
* FirstSQL/J Object/Relational DBMS (
http://www.firstsql.com)