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

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

[Octave-bug-tracker] [bug #62947] nextpow2 gives incorrect result for 0.


From: John W. Eaton
Subject: [Octave-bug-tracker] [bug #62947] nextpow2 gives incorrect result for 0.5 <= x < 1
Date: Wed, 24 Aug 2022 12:27:23 -0400 (EDT)

Follow-up Comment #6, bug #62947 (project octave):

I'd just note that for the original code with


if (f == 0.5)
  n = n - 1;
endif


is not the same as


n(f == 0.5)--


unless the input X is a scalar.  For example, for X = [NaN, Inf, 3, 56, 64],
the original code returned [0, 0, 2, 6, 7] but with logical indexing instead
of the incorrect IF statement, the result is [0, 0, 6, 6].

So the original made the mistake of thinking in scalar terms.


    _______________________________________________________

Reply to this item at:

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

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




reply via email to

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