コード例 #1
0
ファイル: BigInt.cpp プロジェクト: masimun/AMFBach
BigInt::reference BigInt::operator/= ( value o )
{
    if ( o == zero )
        throw std::domain_error ( "Division by zero" );

    bool rsign = false;

    if ( sign_ )
    {
        abs();
        rsign = true;
    }
    if ( o.sign_ )
    {
        o.abs();
        rsign = !rsign;
    }

    BigInt q = zero;
    while ( *this >= 0 )
    {
        operator-= ( o );
        ++q;
    }
    // now, *this + o = r
    --q;

    buffer= q.buffer;
    sign_ = rsign;

    return normalize();
}