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

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

[Octave-bug-tracker] [bug #45481] rem and fmod may give very wrong resul


From: Alexander Klein
Subject: [Octave-bug-tracker] [bug #45481] rem and fmod may give very wrong results for large arguments
Date: Mon, 06 Jul 2015 10:23:51 +0000
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/534.59.10 (KHTML, like Gecko) Version/5.1.9 Safari/534.59.10

URL:
  <http://savannah.gnu.org/bugs/?45481>

                 Summary: rem and fmod may give very wrong results for large
arguments
                 Project: GNU Octave
            Submitted by: matalex
            Submitted on: Mo 06 Jul 2015 10:23:50 GMT
                Category: Octave Function
                Severity: 3 - Normal
                Priority: 5 - Normal
              Item Group: Incorrect Result
                  Status: None
             Assigned to: None
         Originator Name: 
        Originator Email: 
             Open/Closed: Open
         Discussion Lock: Any
                 Release: 3.8.2
        Operating System: *BSD

    _______________________________________________________

Details:

Octave 3.6.4 on OSX and 3.8.2 on FreeBSD may give completely wrong results
when using rem/fmod:


octave:191> rem(1e62,10)
ans =  1.1418e+46


This seems to be caused by the miracles of floating point in conjunction with
literally using the formula from the docs:


octave:196> x=1e62, y=10, x - y .* fix (x ./ y)
x =  1.0000e+62
y =  10
ans = -1.1418e+46


The correct result might be computed much faster using the fmod-function from
libm - see attached program - but maybe there was a reason not to use it, in
the first place?



    _______________________________________________________

File Attachments:


-------------------------------------------------------
Date: Mo 06 Jul 2015 10:23:50 GMT  Name: fmod_test.c  Size: 248B   By: matalex

<http://savannah.gnu.org/bugs/download.php?file_id=34384>

    _______________________________________________________

Reply to this item at:

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

_______________________________________________
  Nachricht gesendet von/durch Savannah
  http://savannah.gnu.org/




reply via email to

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