diff options
Diffstat (limited to '')
-rw-r--r-- | src/number.cpp | 25 |
1 files changed, 13 insertions, 12 deletions
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 | |||
437 | nNum.aInt.append( digit( j ) ); | 437 | nNum.aInt.append( digit( j ) ); |
438 | } | 438 | } |
439 | // Bu::println("New numerator: %1").arg( nNum ); | 439 | // Bu::println("New numerator: %1").arg( nNum ); |
440 | while( iAnchor > -iScale && (!nNum.isZero() || iAnchor > 0)) // division loop | 440 | while( iAnchor >= -iScale && (!nNum.isZero() || iAnchor > 0)) // division loop |
441 | { | 441 | { |
442 | // As long as the numerator is smaller than the divisor we keep | 442 | // As long as the numerator is smaller than the divisor we keep |
443 | // including new digits. | 443 | // including new digits. |
@@ -481,26 +481,26 @@ void Number::divide( const Number &rhs, Number &q, Number &r ) const | |||
481 | r.aInt.append( nNum.aInt[j] ); | 481 | r.aInt.append( nNum.aInt[j] ); |
482 | int jtop = 0; | 482 | int jtop = 0; |
483 | for(; nNum.aInt[jtop] == 0; jtop++ ) { } | 483 | for(; nNum.aInt[jtop] == 0; jtop++ ) { } |
484 | // Bu::println("Computing remainder fraction from %1 to %2") | 484 | // Bu::println("Computing remainder fraction from %1 to %2") |
485 | // .arg( -iAnchor-1 ).arg( jtop ); | 485 | // .arg( -iAnchor-1 ).arg( jtop ); |
486 | r.aFrac.clear(); | 486 | r.aFrac.clear(); |
487 | for( int j = -iAnchor-1, k = 0; j >= jtop && k < r.iScale; j--, k++ ) | 487 | for( int j = -iAnchor-1, k = 0; j >= jtop && k < r.iScale; j--, k++ ) |
488 | { | 488 | { |
489 | if( j < nNum.aInt.getSize() ) | 489 | if( j < nNum.aInt.getSize() ) |
490 | { | 490 | { |
491 | r.aFrac.set( k, nNum.aInt[j] ); | 491 | r.aFrac.set( k, nNum.aInt[j] ); |
492 | // Bu::println("setting %1 to %2").arg( k ).arg( nNum.aInt[j] ); | 492 | // Bu::println("setting %1 to %2").arg( k ).arg( nNum.aInt[j] ); |
493 | } | 493 | } |
494 | } | 494 | } |
495 | } | 495 | } |
496 | /* else | 496 | // else |
497 | { | 497 | // { |
498 | Bu::println("iAnchor: %1").arg( iAnchor ); | 498 | // Bu::println("iAnchor: %1").arg( iAnchor ); |
499 | } | 499 | // } |
500 | Bu::println("Quotient: %1").arg( q ); | 500 | // Bu::println("Quotient: %1").arg( q ); |
501 | Bu::println("Final numerator? %1").arg( nNum ); | 501 | // Bu::println("Final numerator? %1").arg( nNum ); |
502 | Bu::println("Remainder? %1").arg( r ); | 502 | // Bu::println("Remainder? %1").arg( r ); |
503 | */ | 503 | |
504 | } | 504 | } |
505 | 505 | ||
506 | bool Number::isZero() const | 506 | bool Number::isZero() const |
@@ -626,6 +626,7 @@ Number Number::toRadix( int iNewRadix, int iNewScale ) const | |||
626 | n.set( iNewRadix ); | 626 | n.set( iNewRadix ); |
627 | while( !me.isZero() ) | 627 | while( !me.isZero() ) |
628 | { | 628 | { |
629 | Bu::println("%1 %% %2 = %3").arg( me ).arg( n ).arg( me%n ); | ||
629 | int dig = (me%n).toInt32(); | 630 | int dig = (me%n).toInt32(); |
630 | ret.aInt.append( dig ); | 631 | ret.aInt.append( dig ); |
631 | me = me / n; | 632 | me = me / n; |