octave-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Octave-bug-tracker] [bug #31579] Floating point mod function does not m


From: Rik
Subject: [Octave-bug-tracker] [bug #31579] Floating point mod function does not match Matlab
Date: Sun, 07 Nov 2010 19:58:36 +0000
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.12) Gecko/20101027 Ubuntu/9.10 (karmic) Firefox/3.6.12

Follow-up Comment #1, bug #31579 (project octave):

Octave 3.2.4 gets the expected answer.  It uses the script mod.m which
directly calculates:

r = x - y .* floor (x ./ y);


In contrast, the development version of Octave now relies on C libraries for
the mod and rem functions.  At least on two systems, JWE's and mine, the fmod
function yields strange results.  Attached is C++ code to calculate the mod
operation directly, and via the library call to fmod.  The results are
different and don't depend on whether the variable is a float or double.

I also re-coded the test into just C, to make sure there were no C++ calling
C library function issues, and fmod still produces the wrong result.  This is
with glibc 2.10.1 on a 64-bit kernel.

(file #21957)
    _______________________________________________________

Additional Item Attachment:

File name: fmodtst.cpp                    Size:0 KB


    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?31579>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]