diff options
Diffstat (limited to '')
-rw-r--r-- | src/main.cpp | 16 | ||||
-rw-r--r-- | src/number.cpp | 4 |
2 files changed, 14 insertions, 6 deletions
diff --git a/src/main.cpp b/src/main.cpp index a9b0072..4e51020 100644 --- a/src/main.cpp +++ b/src/main.cpp | |||
@@ -259,9 +259,9 @@ void ordertest() | |||
259 | 259 | ||
260 | void radixtest() | 260 | void radixtest() |
261 | { | 261 | { |
262 | Number a( 0, 16 ), b( 0, 16 ); | 262 | Number a( 10, 16 ), b( 10, 16 ); |
263 | 263 | ||
264 | a = "f8a72bce3"; | 264 | a = "1f8a72bbce3"; |
265 | b = "9ea8cb3"; | 265 | b = "9ea8cb3"; |
266 | println("%1 + %2 = %3"). | 266 | println("%1 + %2 = %3"). |
267 | arg( a ). | 267 | arg( a ). |
@@ -290,6 +290,12 @@ void fractest() | |||
290 | a = "12"; | 290 | a = "12"; |
291 | b = "4"; | 291 | b = "4"; |
292 | println("%1 / %2 = %3").arg( a ).arg( b ).arg( a / b ); | 292 | println("%1 / %2 = %3").arg( a ).arg( b ).arg( a / b ); |
293 | |||
294 | a = Number( 100 ); | ||
295 | b = Number( 100 ); | ||
296 | a = "9"; | ||
297 | b = "1.9"; | ||
298 | println("%1 / %2 = %3").arg( a ).arg( b ).arg( a / b ); | ||
293 | } | 299 | } |
294 | 300 | ||
295 | int main( int , char *[] ) | 301 | int main( int , char *[] ) |
@@ -297,9 +303,9 @@ int main( int , char *[] ) | |||
297 | println("CliC"); | 303 | println("CliC"); |
298 | 304 | ||
299 | // packedtest1(); | 305 | // packedtest1(); |
300 | // numbertest1(); | 306 | numbertest1(); |
301 | // numbertestcomp(); | 307 | numbertestcomp(); |
302 | // radixtest(); | 308 | radixtest(); |
303 | fractest(); | 309 | fractest(); |
304 | // ordertest(); | 310 | // ordertest(); |
305 | 311 | ||
diff --git a/src/number.cpp b/src/number.cpp index 15cad95..f9fab26 100644 --- a/src/number.cpp +++ b/src/number.cpp | |||
@@ -248,6 +248,8 @@ void Number::set( const Bu::String &sNum ) | |||
248 | aInt.clear(); | 248 | aInt.clear(); |
249 | aFrac.zero(); | 249 | aFrac.zero(); |
250 | bPositive = true; | 250 | bPositive = true; |
251 | if( sNum.isEmpty() ) | ||
252 | return; | ||
251 | int iPt; | 253 | int iPt; |
252 | for( iPt = 0; iPt < sNum.getSize() && sNum[iPt] != '.'; iPt++ ) { } | 254 | for( iPt = 0; iPt < sNum.getSize() && sNum[iPt] != '.'; iPt++ ) { } |
253 | 255 | ||
@@ -455,7 +457,7 @@ void Number::divide( const Number &rhs, Number &q, Number &r ) const | |||
455 | newrhs.aInt.append( rhs.digit( j ) ); | 457 | newrhs.aInt.append( rhs.digit( j ) ); |
456 | newbase.aInt.append( digit( j ) ); | 458 | newbase.aInt.append( digit( j ) ); |
457 | } | 459 | } |
458 | for( int j = 0; j < aInt.getSize(); j++ ) | 460 | for( int j = rhs.aInt.getSize(); j < aInt.getSize(); j++ ) |
459 | { | 461 | { |
460 | newbase.aInt.append( aInt.get( j ) ); | 462 | newbase.aInt.append( aInt.get( j ) ); |
461 | } | 463 | } |