! division by one unsigned word returns 1 when divisor is zero */
| 1503 | returns 1 when divisor is zero |
| 1504 | */ |
| 1505 | uint DivInt(uint divisor, uint * remainder = 0) |
| 1506 | { |
| 1507 | if( divisor == 0 ) |
| 1508 | { |
| 1509 | if( remainder ) |
| 1510 | *remainder = 0; // this is for convenience, without it the compiler can report that 'remainder' is uninitialized |
| 1511 | |
| 1512 | TTMATH_LOG("UInt::DivInt") |
| 1513 | |
| 1514 | return 1; |
| 1515 | } |
| 1516 | |
| 1517 | if( divisor == 1 ) |
| 1518 | { |
| 1519 | if( remainder ) |
| 1520 | *remainder = 0; |
| 1521 | |
| 1522 | TTMATH_LOG("UInt::DivInt") |
| 1523 | |
| 1524 | return 0; |
| 1525 | } |
| 1526 | |
| 1527 | UInt<value_size> dividend(*this); |
| 1528 | SetZero(); |
| 1529 | |
| 1530 | sint i; // i must be with a sign |
| 1531 | uint r = 0; |
| 1532 | |
| 1533 | // we're looking for the last word in ss1 |
| 1534 | for(i=value_size-1 ; i>0 && dividend.table[i]==0 ; --i); |
| 1535 | |
| 1536 | for( ; i>=0 ; --i) |
| 1537 | DivTwoWords(r, dividend.table[i], divisor, &table[i], &r); |
| 1538 | |
| 1539 | if( remainder ) |
| 1540 | *remainder = r; |
| 1541 | |
| 1542 | TTMATH_LOG("UInt::DivInt") |
| 1543 | |
| 1544 | return 0; |
| 1545 | } |
| 1546 | |
| 1547 | uint DivInt(uint divisor, uint & remainder) |
| 1548 | { |
no outgoing calls
no test coverage detected