summaryrefslogtreecommitdiff
path: root/src/number.cpp
diff options
context:
space:
mode:
authorMike Buland <mike@xagasoft.com>2013-05-10 08:36:15 -0600
committerMike Buland <mike@xagasoft.com>2013-05-10 08:36:15 -0600
commitdc0139c1880d1500b3e275b09781116613862f5f (patch)
tree479c22d0003d14a227040aa939de622067278c55 /src/number.cpp
parent0e5e01b4d0d5f3f872d97c95bd57fd057e4fd5a1 (diff)
downloadclic-dc0139c1880d1500b3e275b09781116613862f5f.tar.gz
clic-dc0139c1880d1500b3e275b09781116613862f5f.tar.bz2
clic-dc0139c1880d1500b3e275b09781116613862f5f.tar.xz
clic-dc0139c1880d1500b3e275b09781116613862f5f.zip
Added more checking & unit-tests.
Diffstat (limited to '')
-rw-r--r--src/number.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/number.cpp b/src/number.cpp
index cab7f46..cda829e 100644
--- a/src/number.cpp
+++ b/src/number.cpp
@@ -12,6 +12,8 @@ Number::Number( int iScale, int iRadix ) :
12 aInt( RadixToBits( iRadix ) ), 12 aInt( RadixToBits( iRadix ) ),
13 aFrac( aInt.getBitWidth(), iScale ) 13 aFrac( aInt.getBitWidth(), iScale )
14{ 14{
15 if( iRadix <= 1 )
16 throw Bu::ExceptionBase("Invalid radix. Radix must be > 1.");
15} 17}
16 18
17Number::Number( const Bu::String &sData, int iScale, int iRadix ) : 19Number::Number( const Bu::String &sData, int iScale, int iRadix ) :
@@ -21,6 +23,9 @@ Number::Number( const Bu::String &sData, int iScale, int iRadix ) :
21 aInt( RadixToBits( iRadix ) ), 23 aInt( RadixToBits( iRadix ) ),
22 aFrac( aInt.getBitWidth(), iScale ) 24 aFrac( aInt.getBitWidth(), iScale )
23{ 25{
26 if( iRadix <= 1 )
27 throw Bu::ExceptionBase("Invalid radix. Radix must be > 1.");
28
24 set( sData ); 29 set( sData );
25} 30}
26 31