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: Rik
Subject: [Octave-bug-tracker] [bug #62947] nextpow2 gives incorrect result for 0.5 <= x < 1
Date: Wed, 24 Aug 2022 12:05:57 -0400 (EDT)

Update of bug #62947 (project octave):

                  Status:          Ready For Test => Fixed                  
             Open/Closed:                    Open => Closed                 

    _______________________________________________________

Follow-up Comment #5:

Thanks for the quick fix.  This entire bug was reported and fixed in
approximately 8 hours.

I made one small change which was to tag the BIST tests that are specific to
this bug report.  See
http://hg.savannah.gnu.org/hgweb/octave/rev/075443476dfb.

For the history, you could try "hg log -f nextpow2.m".  The first interesting
changeset seems to be back in 2018.


changeset:   25236:69b21b8a0e9f
user:        Rik <rik@octave.org>
date:        Thu Apr 12 14:34:10 2018 -0700
summary:     nextpow2.m: Compute value correctly for Inf or NaN inputs (bug
#53463).


and the change was


   [f, n] = log2 (abs (x));
-  n(f == 0.5)--;
+  idx = (n == 0);   # Find any failures of log2 function (n == 0)
+  n(idx) = f(idx);  # and copy over value.
+  n(f == 0.5)--; 


Otherwise, you can go back to the initial code in 1996


changeset:   2539:1dca28c213f0
user:        jwe
date:        Tue Nov 19 23:55:06 1996 +0000
summary:     [project @ 1996-11-19 23:54:48 by jwe]



+  [f, n] = log2 (abs (x));
+  if (f == 0.5)
+    n = n - 1;
+  endif


Apparently, it has just always been this way.

Marking bug as fixed and closing report.


    _______________________________________________________

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]