diff options
| author | Mike Buland <mike@xagasoft.com> | 2014-11-03 08:16:33 -0700 |
|---|---|---|
| committer | Mike Buland <mike@xagasoft.com> | 2014-11-03 08:16:33 -0700 |
| commit | f2f92156531b49da71067336ef0724f411226644 (patch) | |
| tree | 75482cde7f7a1725c2fbf876005763720188fd89 | |
| parent | 55e8d5a372793f6fb7b6f1a6f42396d6115bcf9b (diff) | |
| download | clic-f2f92156531b49da71067336ef0724f411226644.tar.gz clic-f2f92156531b49da71067336ef0724f411226644.tar.bz2 clic-f2f92156531b49da71067336ef0724f411226644.tar.xz clic-f2f92156531b49da71067336ef0724f411226644.zip | |
Made x/0 return 0 for now.
I have to decide how to handle special values like that, but for now
it's better that it doesn't go into an infinite loop.
| -rw-r--r-- | src/number.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/number.cpp b/src/number.cpp index 328cb58..0f99792 100644 --- a/src/number.cpp +++ b/src/number.cpp | |||
| @@ -404,6 +404,18 @@ void Number::set( int32_t iNum ) | |||
| 404 | 404 | ||
| 405 | void Number::divide( const Number &rhs, Number &q, Number &r ) const | 405 | void Number::divide( const Number &rhs, Number &q, Number &r ) const |
| 406 | { | 406 | { |
| 407 | if( rhs.isZero() ) | ||
| 408 | { | ||
| 409 | q = rhs; | ||
| 410 | r.set( 0 ); | ||
| 411 | return; | ||
| 412 | } | ||
| 413 | if( isZero() ) | ||
| 414 | { | ||
| 415 | q = *this; | ||
| 416 | r.set( 0 ); | ||
| 417 | return; | ||
| 418 | } | ||
| 407 | DBS( DIVIDE, Bu::println("divide: %1 / %2").arg( *this ).arg( rhs ) ); | 419 | DBS( DIVIDE, Bu::println("divide: %1 / %2").arg( *this ).arg( rhs ) ); |
| 408 | 420 | ||
| 409 | // iNumShift is how many digits we've shifted the entire equation, | 421 | // iNumShift is how many digits we've shifted the entire equation, |
