Francois Berder / BigInt
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;
 }