From 301844ef30b44966463ab22d6a518bc302330e1e Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Thu, 30 Oct 2014 15:49:41 -0600 Subject: Maybe better? conversions aren't always good. I'm not sure what part is broken yet though. --- src/number.cpp | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/number.cpp b/src/number.cpp index c680a50..9a7da17 100644 --- a/src/number.cpp +++ b/src/number.cpp @@ -437,7 +437,7 @@ void Number::divide( const Number &rhs, Number &q, Number &r ) const nNum.aInt.append( digit( j ) ); } // Bu::println("New numerator: %1").arg( nNum ); - while( iAnchor > -iScale && (!nNum.isZero() || iAnchor > 0)) // division loop + while( iAnchor >= -iScale && (!nNum.isZero() || iAnchor > 0)) // division loop { // As long as the numerator is smaller than the divisor we keep // including new digits. @@ -481,26 +481,26 @@ void Number::divide( const Number &rhs, Number &q, Number &r ) const r.aInt.append( nNum.aInt[j] ); int jtop = 0; for(; nNum.aInt[jtop] == 0; jtop++ ) { } - // Bu::println("Computing remainder fraction from %1 to %2") - // .arg( -iAnchor-1 ).arg( jtop ); +// Bu::println("Computing remainder fraction from %1 to %2") +// .arg( -iAnchor-1 ).arg( jtop ); r.aFrac.clear(); for( int j = -iAnchor-1, k = 0; j >= jtop && k < r.iScale; j--, k++ ) { if( j < nNum.aInt.getSize() ) { r.aFrac.set( k, nNum.aInt[j] ); - // Bu::println("setting %1 to %2").arg( k ).arg( nNum.aInt[j] ); +// Bu::println("setting %1 to %2").arg( k ).arg( nNum.aInt[j] ); } } } -/* else - { - Bu::println("iAnchor: %1").arg( iAnchor ); - } - Bu::println("Quotient: %1").arg( q ); - Bu::println("Final numerator? %1").arg( nNum ); - Bu::println("Remainder? %1").arg( r ); - */ +// else +// { +// Bu::println("iAnchor: %1").arg( iAnchor ); +// } +// Bu::println("Quotient: %1").arg( q ); +// Bu::println("Final numerator? %1").arg( nNum ); +// Bu::println("Remainder? %1").arg( r ); + } bool Number::isZero() const @@ -626,6 +626,7 @@ Number Number::toRadix( int iNewRadix, int iNewScale ) const n.set( iNewRadix ); while( !me.isZero() ) { + Bu::println("%1 %% %2 = %3").arg( me ).arg( n ).arg( me%n ); int dig = (me%n).toInt32(); ret.aInt.append( dig ); me = me / n; -- cgit v1.2.3