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

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

[Octave-bug-tracker] [bug #50278] Incorrect comparison due to numerical


From: Dan Sebald
Subject: [Octave-bug-tracker] [bug #50278] Incorrect comparison due to numerical precision
Date: Sat, 11 Feb 2017 04:55:26 -0500 (EST)
User-agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:50.0) Gecko/20100101 Firefox/50.0

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

Is this an actual error, or simply the nature of floating point arithmetic? 
There may be a symbolic operation to address this, and I sort of recall some
type of "nearly equal" comparison that takes into account distance between
floating point numbers, but I can't recall the name if it does exist.  It
would be a comparison something like the following:


for k = 1:7
    t(k)=(k-1)*0.1; 
    if t(k) <= 0.3 + eps
        M(k) = 0;
    else
        M(k) = 2;
    end
end


    _______________________________________________________

Reply to this item at:

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

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




reply via email to

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