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

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

[Octave-bug-tracker] [bug #42583] log2() returns inaccurate result for m


From: Rik
Subject: [Octave-bug-tracker] [bug #42583] log2() returns inaccurate result for many integer powers of 2, unlike Matlab
Date: Sat, 25 Feb 2023 15:37:21 -0500 (EST)

Follow-up Comment #20, bug #42583 (project octave):

The code for pow2 is in libinterp/corefcn/pow2.cc.  For doubles,


for (octave_idx_type i = 0; i < y.numel (); i++)
  y.xelem (i) = std::exp2 (x.xelem (i));


So, Octave is just making use of the C++ math library.

On my machine,


pow2 (-1026:-1020)
ans =

  1.4e-309  2.8e-309  5.6e-309  1.1e-308  2.2e-308  4.5e-308  8.9e-308


But this is just with very simple compile flags "-O2 -pipe".




    _______________________________________________________

Reply to this item at:

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

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




reply via email to

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