4 Replies Latest reply: Oct 16, 2007 3:35 PM by 807605 RSS

    Bits to BigInteger

    807605
      Hi friends!,

      I want to convert a bit set in a BigInteger. I have tried with a byte array but I have the following problem:

      BigInteger a = new BigInteger(new byte[]{127});

      !That is good!, because when I print my BigInteger the value is 127.

      BigInteger a = new BigInteger(new byte[]{1,127});

      That is wrong because my BigInteger print 383, that is equivalent to 101111111. The BigInteger put the sign bit (from 127) in my BigInteger.

      I was waiting 255. That is equivalent to 11111111

      Can you help me?

      Thanks in advance.