|
Post by graham on Aug 1, 2010 12:25:09 GMT -5
Hi, congratulation on the library, it is simply amazing.
I am having a slight issue with the biginteger class when initialising from a byte array. For a given Byte array b, i have used
Set bigintvalue = BInt(b) and then have check that the array has been set correctly with Dim c() As Byte c = urltobigint.ToArray which results in an identical array as expected.
But the number produced when looking at the .ToString is not as expected. The byte array: CDDA00AEEEB14D48882DFBC55DAA6504 Should result in a decimal value of: 273623673710640401018044282812286788868 which is correct when using java's bigint, but a different value is returned here.
I am not not sure where abouts i am going wrong, but any help would be appreciated.
|
|
|
Post by Kelly Ethridge on Aug 1, 2010 19:58:27 GMT -5
Hello graham,
The problem comes from determining if the byte array contains a negative value or not. I check the highest bit for this and assume it's negative if set. If you were to resize the array with an extra 4 bytes, the parser will treat the byte array as positive. Padding the end(left most) with 4 bytes of zeros ensures a positive number. I know this is a kludge and may be difficult to support all scenarios. It's one of the things on the list to improve when I get a chance.
Kelly
|
|
|
Post by graham on Aug 3, 2010 9:45:53 GMT -5
Thank you, that is brilliant, and now working perfectly . The extra 4 bytes are no problem, as i am working with fixed length byte arrays. Thanks again for the help.
|
|