Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

## Re: [Sdcc-user] Signed divides

 Re: [Sdcc-user] Signed divides From: Vangelis Rokas - 2004-10-07 01:36:09 ```----- Original Message ----- From: "George M. Gallant" To: Subject: [Sdcc-user] Signed divides > There is a problem with the signed divide routines. They typically > return the negative of the correct result. Futher digging seems to > point at compound "if" statements. I tried two schemes to calculate > the sign that failed. Its time to fix this stupid bug... It will be the next thing to fix after I finish debugging of functions with variable arguments and get printf_small to work... (its difficult, believe me!) regards, Vangelis ```

 [Sdcc-user] Signed divides From: George M. Gallant - 2004-10-06 23:33:27 ```There is a problem with the signed divide routines. They typically return the negative of the correct result. Futher digging seems to point at compound "if" statements. I tried two schemes to calculate the sign that failed. The follow code snippet executes incorrectly: char a, b, c; a = 20; b = 5; c = a / b; c returns 0xFC which is -4. Change b to -5 and c returns 4. The following snippet also fails: c = 0; if ((a < 0) ^ (b < 0) c = 1; These results were obtained on a 18f252 with sdcc 2.4.5. BTW, the unsigned div routines which do most of the work seem ok. George ```
 Re: [Sdcc-user] Signed divides From: Vangelis Rokas - 2004-10-07 01:36:09 ```----- Original Message ----- From: "George M. Gallant" To: Subject: [Sdcc-user] Signed divides > There is a problem with the signed divide routines. They typically > return the negative of the correct result. Futher digging seems to > point at compound "if" statements. I tried two schemes to calculate > the sign that failed. Its time to fix this stupid bug... It will be the next thing to fix after I finish debugging of functions with variable arguments and get printf_small to work... (its difficult, believe me!) regards, Vangelis ```