I started using the .NET 4 System.Numerics.BigInteger Structure and I ran into a problem.
I am trying to parse a string containing an unsigned hexadecimal number (positive). I get a negative number.
For example, I make the following two statements:
Assert.IsTrue(System.Int64.Parse("8", NumberStyles.HexNumber, CultureInfo.InvariantCulture) > 0, "Int64"); Assert.IsTrue(System.Numerics.BigInteger.Parse("8", NumberStyles.HexNumber, CultureInfo.InvariantCulture) > 0, "BigInteger");
The first statement succeeds; the second statement fails. I actually get -8 instead of 8 in BigInteger .
The problem is that I hex starts with 1 bit, not 0 bits (a digit between 8 and F inclusive). If I add a leading 0, everything will work fine.
Is this a bad use on my part? Is this a bug in BigInteger ?
source share