fix bugs with bigint

This commit is contained in:
Daniel Larimer 2013-08-14 01:11:48 -04:00
parent 786941fe69
commit f954ff1a25
2 changed files with 9 additions and 1 deletions

View file

@ -44,6 +44,7 @@ namespace fc {
bigint operator /= ( const bigint& a );
bigint operator *= ( const bigint& a );
bigint& operator += ( const bigint& a );
bigint& operator -= ( const bigint& a );
bigint& operator <<= ( uint32_t i );
bigint& operator >>= ( uint32_t i );
bigint operator - ( const bigint& a )const;

View file

@ -59,7 +59,7 @@ namespace fc {
return BN_cmp( n, c.n ) == 0;
}
bool bigint::operator != ( const bigint& c )const {
return BN_cmp( n, c.n ) == 0;
return BN_cmp( n, c.n ) != 0;
}
bigint::operator bool()const
{
@ -97,6 +97,13 @@ namespace fc {
std::swap(*this,tmp);
return *this;
}
bigint& bigint::operator -= ( const bigint& a ){
bigint tmp(*this);
BN_sub( tmp.n, n, a.n );
std::swap(*this,tmp);
return *this;
}
bigint bigint::operator * ( const bigint& a )const {
BN_CTX* ctx = BN_CTX_new();