Small bug on subtraction in dumbmp.c

Marcelo Anabuki marceloanabuki at
Mon Oct 24 21:40:18 CEST 2011


I am porting the dumbmp version of the lib to an embedded system.

I found a small problem with the subtraction of two large numbers. I also
attached a quick fix for the problem. Hopefully it will be useful to you


gcc version 4.1.2 20080704 (Red Hat 4.1.2-46)

make command:
gcc -o teste main.c

Run the compiled file the output should look something like this:

a = 1000000000
b = 10
c = 2000000000
sgn(a) = 1
r = a*11
r = 28fa6ae00

r1 = b - 20
sgn(r1) = -1

*r2 = a - a*11*
*sgn(r2) = 1*

r3 = a*11 - a
sgn(r3) = 1

r4 = a - c
sgn(r4) = -1

The r2 result has the wrong signal. It is supposed to be negative. If you
change the include file to dumbmp_quick_fix.c it solves this small issue.

Anabuki, Marcelo
marceloanabuki at
-------------- next part --------------
A non-text attachment was scrubbed...
Name: dumbmp.tar
Type: application/x-tar
Size: 40960 bytes
Desc: not available
URL: <>

More information about the gmp-bugs mailing list