Date: Mon, 22 May 2000 08:36:52 -0500 From: Eric Rudd Subject: Re: Bug 314 To: djgpp-workers AT delorie DOT com Message-id: <392937F4.B78491A5@cyberoptics.com> Organization: CyberOptics MIME-version: 1.0 X-Mailer: Mozilla 4.72 [en] (Win95; U) Content-type: text/plain; charset=us-ascii Content-transfer-encoding: 7bit X-Accept-Language: en References: <39257FA1 DOT 65CAAC89 AT cyberoptics DOT com> Reply-To: djgpp-workers AT delorie DOT com 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 div_t --- 1,4 ---- ! /* Copyright (C) 2000 DJ Delorie, see COPYING.DJ for details */ #include 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 div_t --- 1,4 ---- ! /* Copyright (C) 2000 DJ Delorie, see COPYING.DJ for details */ #include 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