Saturday, February 15, 2014

BigInteger Bit Length

   I was looking for Miller Rabin implementation in .Net (vb or c#) and found one. I went through the code and apparently I needed to generate a random BigInteger hence why I made THIS. Another thing I noticed was the algorithm needed that random number to be the same length as the number to be checked. Now I don't know how precise this length had to be whether it was just bytes or bits. But I saw something I didn't like and I sought out to 'change' it (might not be broken to say 'fix').

Number = 8739
In Hex = 2223
Actual = 15
Report = 16 (using BigInteger.ToByteArray.Length * 8)

That lack of precision kinda bugged me lol and so:
Note: If there is a better way (which I'm sure there is) please let me know in the comments.

No comments: