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

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

[Octave-bug-tracker] [bug #64692] colon range includes an extra value


From: John W. Eaton
Subject: [Octave-bug-tracker] [bug #64692] colon range includes an extra value
Date: Sat, 23 Sep 2023 08:13:04 -0400 (EDT)

Update of bug #64692 (project octave):

                  Status:         Patch Submitted => Confirmed              

    _______________________________________________________

Follow-up Comment #26:

I just noticed the inconsistency with 1.8:0.05:1.9 (Octave produces one value
and Matlab produces 2).

That problem appears to be due to not using a tolerant comparison when
attempting to detect ranges that produce a single value.  So we probably need
something like this change (there may be a better way to do it):


diff --git a/liboctave/array/Range.cc b/liboctave/array/Range.cc
--- a/liboctave/array/Range.cc
+++ b/liboctave/array/Range.cc
@@ -219,8 +219,9 @@ xinit (T base, T limit, T inc, bool reve
   // The following case also catches Inf values for increment when
   // there will be only one element.
 
-  if ((limit <= base && base + inc < limit)
-      || (limit >= base && base + inc > limit))
+  if (((limit <= base && base + inc < limit)
+       || (limit >= base && base + inc > limit))
+      && ! xteq (base + inc, limit))
     {
       final_val = base;
       nel = 1;




    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?64692>

_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/




reply via email to

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