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: Arun Giridhar
Subject: [Octave-bug-tracker] [bug #64692] colon range includes an extra value
Date: Fri, 22 Sep 2023 16:09:34 -0400 (EDT)

Follow-up Comment #18, bug #64692 (project octave):

My previous comment got mis-formatted by the asterisks. Read the
multiplication signs where it becomes bold.

[comment #15 comment #15:]
> HOWEVER, for the example shown in the initial submission, maybe we are just
missing the fact that the beginning value and the increment *are* integers, so
we shouldn't need to use the tolerant comparison to compute the number of
elements and if the final target value is not an integer, it should never be
included in the final set of values and we should never include any value that
is outside that range?

This hinges on what the value of (0.3 - 0.2 - 0.1) "ought" to be. Currently we
interpret it as "close to zero and intended to be zero" and act on that basis.
As I mentioned in my comment #2, this is less astonishing to me than applying
strict rounding rules, because as we see in Matlab's case, it misses the
"intended" end point of zero.

In either case, coding that as any of these would work:


b = 0.3 - 0.2 - 0.1;
b = round (b * 1e12) / 1e12;
-2 : 1 : b



hi = 0.3 - 0.2 - 0.1;
lo = -2;
N = 2;
(0:N) * (hi - lo) / N + lo


Etc.


    _______________________________________________________

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]