Hey i have a program and i overloaded the + operator and for this one set of numbers -888+-112 i get the wrong number, i ran GDB and this is what i get maybe someone can see why c is getting set to the weird number of 134489 when temp is showing its 0.
Code:
538 if(count == c.numDigits)
(gdb) print count
$11 = 3
(gdb) print c.numDigits
$12 = 3
(gdb)
$13 = 3
(gdb) n
541 temp = c.digits;
(gdb) print temp
$14 = (int *) 0xb7f1221f
(gdb) print *temp
$15 = -273227
(gdb) print c
$16 = (BigInt &) @0xbfe13498: {digits = 0x80502a0, numDigits = 3,
positive = false}
(gdb) print c.digits[2]
$17 = 0
(gdb) print c.digits[1]
$18 = 0
(gdb) print c.digits[0]
$19 = 0
(gdb)
$20 = 0
(gdb) n
544 c.numDigits++;
(gdb) print *temp
$21 = 0
(gdb) n
547 c.digits = new int [c.numDigits];
(gdb) n
550 for(i = 1; i<=c.numDigits; i++)
(gdb) print c
$22 = (BigInt &) @0xbfe13498: {digits = 0x8050008, numDigits = 4,
positive = false}
(gdb) n
552 c.digits[c.numDigits-i] = temp[c.numDigits-i];
(gdb)
550 for(i = 1; i<=c.numDigits; i++)
(gdb) print c.digits[3]
$23 = 134489