kolombet / as3crypto

Automatically exported from code.google.com/p/as3crypto
1 stars 0 forks source link

Constructor of BigInteger doesn't support negative numbers #61

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
var a:BigInteger = new BigInteger("3", 16);
var b:BigInteger = new BigInteger("-3", 16);
trace(a, b);
var r:BigInteger = a.add(b);
trace(r);

What is the expected output? What do you see instead?
Expected:
3 -3
0

Got:
3 fd
100

What version of the product are you using? On what operating system?
AsCrypto 1.3

Please provide any additional information below.
It looks like it's incomplete... fd is indeed -3 if you do sign extension, but 
signInt() returns 1 instead.

Extending the class BigInteger with one more operation setSignInt() doesn't 
work.

To get a -3 BigInteger, i did:
var b:BigInteger = new BigInteger("3", 16);
b = BigInteger.ZERO.substract(b);

Original issue reported on code.google.com by v.oliv...@gmail.com on 7 May 2011 at 8:08