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: anonymous
Subject: [Octave-bug-tracker] [bug #50278] Incorrect comparison due to numerical precision
Date: Fri, 10 Feb 2017 18:17:10 -0500 (EST)
User-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36

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

                 Summary: Incorrect comparison due to numerical precision
                 Project: GNU Octave
            Submitted by: None
            Submitted on: Fri 10 Feb 2017 11:17:09 PM UTC
                Category: None
                Severity: 3 - Normal
                Priority: 5 - Normal
              Item Group: Incorrect Result
                  Status: None
             Assigned to: None
         Originator Name: 
        Originator Email: address@hidden
             Open/Closed: Open
         Discussion Lock: Any
                 Release: 4.2.0
        Operating System: Microsoft Windows

    _______________________________________________________

Details:

The simple script below results in an error.  When k=4, t(4) = 0.3 but is not
<= 0.3 due to numerical precision. 


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


Gives result:

>>t
t = 0.00000   0.10000   0.20000   0.30000   0.40000   0.50000   0.60000
>>M
M = 0   0   0   2   2   2   2
>>t(4) - 0.3
ans =   5.5511e-017


Octave 4.2.0 is configured for "x86_64-w64-minw32" running on Windows 10 Home,
Intel Core 17-7500U




    _______________________________________________________

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]