| 2317 | |
| 2318 | |
| 2319 | void Div3_MultiplySubtract( UInt<value_size+1> & uu, |
| 2320 | const UInt<value_size+1> & vv, uint & qp) |
| 2321 | { |
| 2322 | // D4 (in the book) |
| 2323 | |
| 2324 | UInt<value_size+1> vv_temp(vv); |
| 2325 | vv_temp.MulInt(qp); |
| 2326 | |
| 2327 | if( uu.Sub(vv_temp) ) |
| 2328 | { |
| 2329 | // there was a carry |
| 2330 | |
| 2331 | // |
| 2332 | // !!! this part of code was not tested |
| 2333 | // |
| 2334 | |
| 2335 | --qp; |
| 2336 | uu.Add(vv); |
| 2337 | |
| 2338 | // can be a carry from this additions but it should be ignored |
| 2339 | // because it cancels with the borrow from uu.Sub(vv_temp) |
| 2340 | } |
| 2341 | |
| 2342 | TTMATH_LOG("UInt::Div3_MultiplySubtract") |
| 2343 | } |
| 2344 | |
| 2345 | |
| 2346 | |