result = lhs * rhs */
| 447 | |
| 448 | /* result = lhs * rhs */ |
| 449 | static void |
| 450 | BigInt_Multiply_int(BigInt *result, const BigInt *lhs, npy_uint32 rhs) |
| 451 | { |
| 452 | /* perform long multiplication */ |
| 453 | npy_uint32 carry = 0; |
| 454 | npy_uint32 *resultCur = result->blocks; |
| 455 | const npy_uint32 *pLhsCur = lhs->blocks; |
| 456 | const npy_uint32 *pLhsEnd = lhs->blocks + lhs->length; |
| 457 | for ( ; pLhsCur != pLhsEnd; ++pLhsCur, ++resultCur) { |
| 458 | npy_uint64 product = (npy_uint64)(*pLhsCur) * rhs + carry; |
| 459 | *resultCur = (npy_uint32)(product & bitmask_u64(32)); |
| 460 | carry = product >> 32; |
| 461 | } |
| 462 | |
| 463 | /* if there is a remaining carry, grow the array */ |
| 464 | if (carry != 0) { |
| 465 | /* grow the array */ |
| 466 | DEBUG_ASSERT(lhs->length + 1 <= c_BigInt_MaxBlocks); |
| 467 | *resultCur = (npy_uint32)carry; |
| 468 | result->length = lhs->length + 1; |
| 469 | } |
| 470 | else { |
| 471 | result->length = lhs->length; |
| 472 | } |
| 473 | } |
| 474 | |
| 475 | /* result = in * 2 */ |
| 476 | static void |
no test coverage detected