Small bug on subtraction in dumbmp.c

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


Hello,

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
guys.

Instructions:

gcc version 4.1.2 20080704 (Red Hat 4.1.2-46)
gmp-5.0.2

make command:
gcc -o teste main.c

Description:
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 redewireless.net
-------------- next part --------------
A non-text attachment was scrubbed...
Name: dumbmp.tar
Type: application/x-tar
Size: 40960 bytes
Desc: not available
URL: <http://gmplib.org/list-archives/gmp-bugs/attachments/20111024/98faedfb/attachment-0001.tar>


More information about the gmp-bugs mailing list