Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: BigInt.cpp
- Revision:
- 6:29e78b169f40
- Parent:
- 5:beeb31f340a7
- Child:
- 7:1aad58757705
diff -r beeb31f340a7 -r 29e78b169f40 BigInt.cpp
--- a/BigInt.cpp Fri Oct 04 12:38:42 2013 +0000
+++ b/BigInt.cpp Fri Oct 04 14:39:15 2013 +0000
@@ -336,6 +336,15 @@
while(result > b)
result -= b;
+ // trim result
+ uint8_t *tmp = (uint8_t*)result.bits;
+ uint32_t newSize = result.size;
+ while(tmp[newSize-1] == 0 && newSize > 0)
+ newSize--;
+ if(num(newSize) < num(result.size))
+ result.bits = (uint32_t*)realloc(result.bits, sizeof(uint32_t)*num(newSize));
+ result.size = newSize;
+
return result;
}