summaryrefslogtreecommitdiff
path: root/src/number.cpp
diff options
context:
space:
mode:
authorMike Buland <mike@xagasoft.com>2013-04-22 13:04:25 -0600
committerMike Buland <mike@xagasoft.com>2013-04-22 13:04:25 -0600
commitd7ccd9c4d8e5a5bb4f12b36b3e4ad3105c5a9317 (patch)
treea7b6753b6a049be68a91749aaae8da23979ed83a /src/number.cpp
parenta520fc5740da7d50a289357e4e6e529b826454e7 (diff)
downloadclic-d7ccd9c4d8e5a5bb4f12b36b3e4ad3105c5a9317.tar.gz
clic-d7ccd9c4d8e5a5bb4f12b36b3e4ad3105c5a9317.tar.bz2
clic-d7ccd9c4d8e5a5bb4f12b36b3e4ad3105c5a9317.tar.xz
clic-d7ccd9c4d8e5a5bb4f12b36b3e4ad3105c5a9317.zip
Fixed bug in multiply, added toInt32 function.
Multiply was ignoring the zero column, which was odd. I fixed this other places but apparently missed multiply.
Diffstat (limited to 'src/number.cpp')
-rw-r--r--src/number.cpp14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/number.cpp b/src/number.cpp
index b7a420c..d95ab90 100644
--- a/src/number.cpp
+++ b/src/number.cpp
@@ -63,7 +63,7 @@ Number Number::operator*( const Number &rhs ) const
63// Bu::println("Pos %1").arg(j); 63// Bu::println("Pos %1").arg(j);
64 int iPos = iCarry; 64 int iPos = iCarry;
65 iCarry = 0; 65 iCarry = 0;
66 for( int k = 1-rhs.iScale; k < rhs.aInt.getSize(); k++ ) 66 for( int k = -rhs.iScale; k < rhs.aInt.getSize(); k++ )
67 { 67 {
68// if( j-k < 0 ) 68// if( j-k < 0 )
69// break; 69// break;
@@ -566,6 +566,18 @@ void Number::setScale( int iNewScale )
566 iScale = iNewScale; 566 iScale = iNewScale;
567} 567}
568 568
569int32_t Number::toInt32() const
570{
571 int32_t ret = 0;
572 int32_t ord = 1;
573 for( int j = 0; j < aInt.getSize(); j++ )
574 {
575 ret += ord * aInt.get( j );
576 ord *= iRadix;
577 }
578 return ret;
579}
580
569Number Number::add( const Number &rhs, bool bSub ) const 581Number Number::add( const Number &rhs, bool bSub ) const
570{ 582{
571 Number ret( Bu::buMax(iScale,rhs.iScale), iRadix ); 583 Number ret( Bu::buMax(iScale,rhs.iScale), iRadix );