summaryrefslogtreecommitdiff
path: root/src/number.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/number.cpp')
-rw-r--r--src/number.cpp22
1 files changed, 18 insertions, 4 deletions
diff --git a/src/number.cpp b/src/number.cpp
index 062e368..eb4d01d 100644
--- a/src/number.cpp
+++ b/src/number.cpp
@@ -306,15 +306,22 @@ void Number::set( const Bu::String &sNum )
306 } 306 }
307 for( ; iEnd < sNum.getSize() && sNum[iEnd] == '0'; iEnd++ ) { } 307 for( ; iEnd < sNum.getSize() && sNum[iEnd] == '0'; iEnd++ ) { }
308 308
309 int iDigit;
309 for( int j = iPt-1; j >= iEnd; j-- ) 310 for( int j = iPt-1; j >= iEnd; j-- )
310 { 311 {
311// Bu::println(" -> '%1'").arg( sNum[j] ); 312// Bu::println(" -> '%1'").arg( sNum[j] );
312 if( sNum[j] == '.' ) 313 if( sNum[j] == '.' )
313 break; 314 break;
314 if( sNum[j] >= '0' && sNum[j] <= '9' ) 315 if( sNum[j] >= '0' && sNum[j] <= '9' )
315 aInt.append( sNum[j]-'0' ); 316 iDigit = sNum[j]-'0';
316 else 317 else
317 aInt.append( sNum[j]-'a'+10 ); 318 iDigit = sNum[j]-'a'+10;
319 if( iDigit < 0 || iDigit >= iRadix )
320 throw Bu::ExceptionBase(Bu::String(
321 "Invalid character '%1' in Number::set").arg(sNum[j]).
322 end().getStr()
323 );
324 aInt.append( iDigit );
318 } 325 }
319 326
320 if( iScale > 0 ) 327 if( iScale > 0 )
@@ -324,9 +331,16 @@ void Number::set( const Bu::String &sNum )
324 { 331 {
325// Bu::println(" => '%1'").arg( sNum[j] ); 332// Bu::println(" => '%1'").arg( sNum[j] );
326 if( sNum[j] >= '0' && sNum[j] <= '9' ) 333 if( sNum[j] >= '0' && sNum[j] <= '9' )
327 aFrac.set( iFrac++, sNum[j]-'0' ); 334 iDigit = sNum[j]-'0';
328 else 335 else
329 aFrac.set( iFrac++, sNum[j]-'a'+10 ); 336 iDigit = sNum[j]-'a'+10;
337
338 if( iDigit < 0 || iDigit >= iRadix )
339 throw Bu::ExceptionBase(Bu::String(
340 "Invalid character '%1' in Number::set").arg(sNum[j]).
341 end().getStr()
342 );
343 aFrac.set( iFrac++, iDigit );
330 if( iFrac >= iScale ) 344 if( iFrac >= iScale )
331 break; 345 break;
332 } 346 }