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 15:58:59 -0400 (EDT)

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

[comment #14 comment #14:]
> I'm beginning to think Octave should unconditionally issue a loud warning
when a range is specified with non-integer values.
> 

Good idea. The Symbolic package does something similar already. There was also
the related topic that Range objects may be removed from Octave and replaced
with conventional arrays. If that's happening soon, the two changes could be
combined, otherwise the warning is good to go by itself.

I'll add a section to the manual hopefully in the next few days documenting
these pitfalls. It's a hairy problem if users rely on (0.3 - 0.2 - 0.1) to be
strictly less than / greater than / equal to zero, and if such behavior relies
on deep implementation details.

One place where floating point rounding is explicitly guarded against is in in
tsearch.cc, to determine if a point is inside or outside a triangle. The
tolerance used there is 1e-12. Anything smaller is deemed to be noise.

>From examining my production Octave code with grep, it seems I don't use
floating-point ranges at all; it was never a conscious choice, but it was
easier for me to think in terms of "(0:N) * slope + base", so "(0:2) * 0.1 / 2
+ 1.8" instead of "1.8 : 0.05 : 1.9". In any case, they are all saved as
arrays / vectors / matrices, so the initial range calculation is always on
integer values. 


    _______________________________________________________

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]