* Returns 0 if (lhs = rhs), negative if (lhs < rhs), positive if (lhs > rhs) */
| 288 | * Returns 0 if (lhs = rhs), negative if (lhs < rhs), positive if (lhs > rhs) |
| 289 | */ |
| 290 | static npy_int32 |
| 291 | BigInt_Compare(const BigInt *lhs, const BigInt *rhs) |
| 292 | { |
| 293 | int i; |
| 294 | |
| 295 | /* A bigger length implies a bigger number. */ |
| 296 | npy_int32 lengthDiff = lhs->length - rhs->length; |
| 297 | if (lengthDiff != 0) { |
| 298 | return lengthDiff; |
| 299 | } |
| 300 | |
| 301 | /* Compare blocks one by one from high to low. */ |
| 302 | for (i = lhs->length - 1; i >= 0; --i) { |
| 303 | if (lhs->blocks[i] == rhs->blocks[i]) { |
| 304 | continue; |
| 305 | } |
| 306 | else if (lhs->blocks[i] > rhs->blocks[i]) { |
| 307 | return 1; |
| 308 | } |
| 309 | else { |
| 310 | return -1; |
| 311 | } |
| 312 | } |
| 313 | |
| 314 | /* no blocks differed */ |
| 315 | return 0; |
| 316 | } |
| 317 | |
| 318 | /* result = lhs + rhs */ |
| 319 | static void |
no outgoing calls
no test coverage detected