summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/number.cpp14
-rw-r--r--src/number.h2
2 files changed, 15 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 );
diff --git a/src/number.h b/src/number.h
index 8c9cd28..0816a17 100644
--- a/src/number.h
+++ b/src/number.h
@@ -46,6 +46,8 @@ public:
46 int getScale() const { return iScale; } 46 int getScale() const { return iScale; }
47 void setScale( int iNewScale ); 47 void setScale( int iNewScale );
48 48
49 int32_t toInt32() const;
50
49private: 51private:
50 Number add( const Number &rhs, bool bSub ) const; 52 Number add( const Number &rhs, bool bSub ) const;
51 53