|
From: | Dmitri A. Sergatskov |
Subject: | [Octave-bug-tracker] [bug #42583] log2() returns inaccurate result for many integer powers of 2, unlike Matlab |
Date: | Sat, 25 Feb 2023 15:58:49 -0500 (EST) |
Follow-up Comment #21, bug #42583 (project octave): I compiled with default optimization flags both 64-bit pointer and 32-bit pointer. The result is the same. With 32-bit pointers I got the same answer as Rik: octave:1> __octave_config_info__ ("config_opts") ans = octave:2> 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 With 64-bit pointers: ctave:1> __octave_config_info__ ("config_opts") ans = '--enable-64' '--with-blas=flexiblas64' '--with-qrupdate=qrupdate64' '--with-suitesparseconfig=suitesparseconfig64' '--with-amd=amd64' '--with-camd=camd64' '--with-colamd=colamd64' '--with-ccolamd=ccolamd64' '--with-cholmod=cholmod64' '--with-spqr=spqr64' '--with-cxsparse=cxsparse64' '--with-umfpack=umfpack64' '--with-klu=klu64' '--with-arpack=arpack64' '--without-sundials_nvecserial' '--without-sundials_ida' '--without-sundials_sunlinsolklu' octave:2> pow2 (-1026:-1020) ans = 0 0 0 0 2.2e-308 4.5e-308 8.9e-308 I also tried clang (32-bit and 64-bit) -- the same discrepancy. Trying smaller steps: octave:37> pow2 (-(1022+257*eps)) ans = 0 octave:38> pow2 (-(1022+256*eps)) ans = 2.2251e-308 octave:39> format bit octave:40> -(1022+257*eps) ans = 1100000010001111111100000000000000000000000000000000000000000001 octave:41> -(1022+256*eps) ans = 1100000010001111111100000000000000000000000000000000000000000000 Dmitri. -- _______________________________________________________ Reply to this item at: <https://savannah.gnu.org/bugs/?42583> _______________________________________________ Message sent via Savannah https://savannah.gnu.org/
[Prev in Thread] | Current Thread | [Next in Thread] |