This is the mail archive of the glibc-bugs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug math/23395] New: fmod repeated subtraction algorithm introduces round off errors


https://sourceware.org/bugzilla/show_bug.cgi?id=23395

            Bug ID: 23395
           Summary: fmod repeated subtraction algorithm introduces round
                    off errors
           Product: glibc
           Version: unspecified
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: math
          Assignee: unassigned at sourceware dot org
          Reporter: irv at princeton dot com
  Target Milestone: ---

Created attachment 11120
  --> https://sourceware.org/bugzilla/attachment.cgi?id=11120&action=edit
Source code that illustrates the problem.

Consider the attached source code that computes fmod(x, y) for the values
x=100, 10, ..., 1.0e-6, y = x/100.  The result should always be close to 0. The
problem is that the fmod() implementation in sysdeps/ieee754/dbl-64/e_fmod.c
does repeated subtraction, which causes round off error to accumulate.

For the case where x > 0, y > 0, y < x, I show a different algorithm in
newfmod() that avoids that round off error.

This is on Intel chips, under Ubuntu (but it happens for any distribution on
Intel).

Since the implementation of fmod() is 25 years old, it ought to be fixed.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]