Mail Archives: djgpp-workers/2000/05/22/09:37:01
Eric Rudd wrote:
> OK, I submitted a "solution" to Bug 314, but I'll see if I can run the diffs
> this weekend and get them uploaded.
Here they are:
*** src/libc/ansi/stdlib/div.old Sat Dec 10 22:33:46 1994
--- src/libc/ansi/stdlib/div.c Fri May 19 13:04:36 2000
***************
*** 1,4 ****
! /* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
#include <stdlib.h>
div_t
--- 1,4 ----
! /* Copyright (C) 2000 DJ Delorie, see COPYING.DJ for details */
#include <stdlib.h>
div_t
***************
*** 6,24 ****
{
div_t r;
- if (num > 0 && denom < 0) {
- num = -num;
- denom = -denom;
- }
- r.quot = num / denom;
r.rem = num % denom;
! if (num < 0 && denom > 0)
! {
! if (r.rem > 0)
! {
! r.quot++;
! r.rem -= denom;
! }
! }
return r;
}
--- 6,13 ----
{
div_t r;
r.rem = num % denom;
! r.quot = num / denom;
!
return r;
}
*** src/libc/ansi/stdlib/div.old Sat Dec 10 22:33:46 1994
--- src/libc/ansi/stdlib/div.c Fri May 19 13:04:36 2000
***************
*** 1,4 ****
! /* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
#include <stdlib.h>
div_t
--- 1,4 ----
! /* Copyright (C) 2000 DJ Delorie, see COPYING.DJ for details */
#include <stdlib.h>
div_t
***************
*** 6,24 ****
{
div_t r;
- if (num > 0 && denom < 0) {
- num = -num;
- denom = -denom;
- }
- r.quot = num / denom;
r.rem = num % denom;
! if (num < 0 && denom > 0)
! {
! if (r.rem > 0)
! {
! r.quot++;
! r.rem -= denom;
! }
! }
return r;
}
--- 6,13 ----
{
div_t r;
r.rem = num % denom;
! r.quot = num / denom;
!
return r;
}
I have done my own testing, and believe that these modified routines now conform
to the requirements of ANSI, but I would appreciate it if someone else took a
look at the code and verified that the new code is indeed correct.
-Eric Rudd
rudd AT cyberoptics DOT com
- Raw text -