public inbox for glibc-bugs@sourceware.org help / color / mirror / Atom feed
From: "mwelinder at gmail dot com" <sourceware-bugzilla@sourceware.org> To: glibc-bugs@sourceware.org Subject: [Bug math/28472] New: pow(10, i) accuracy Date: Mon, 18 Oct 2021 23:54:35 +0000 [thread overview] Message-ID: <bug-28472-131@http.sourceware.org/bugzilla/> (raw) https://sourceware.org/bugzilla/show_bug.cgi?id=28472 Bug ID: 28472 Summary: pow(10, i) accuracy Product: glibc Version: 2.31 Status: UNCONFIRMED Severity: normal Priority: P2 Component: math Assignee: unassigned at sourceware dot org Reporter: mwelinder at gmail dot com Target Milestone: --- Created attachment 13725 --> https://sourceware.org/bugzilla/attachment.cgi?id=13725&action=edit Test program When the attached test program is run, I see two cases where pow(10,i) disagrees with atof(1e$i") for an integer i. This is a last-bit rounding issue. The values returned by pow(10,i) are very close and normally I would cut pow a bit of slack -- it is a lot trickier than the single-argument functions like sin, cos, or exp. However, pow(10,i) is a fairly important case that it would make sense to handle accurately. $ ./a.out i = 23 a = 100000000000000008388608 b = 99999999999999991611392 Midpoint i = 210 a = 1000000000000000073111882183254852571116159535704205070042237624441112422237792851875363410143857412667610687999697631253349027916052430446705469082528474390439305760542775847335624615778546587814778848485048320 b = 999999999999999927113782419344605574598668153294882673458925392487194643703632279098558059466181044478400725843812838336795121561031396504666917998514458446354143529431921823271795036250068185162804696593727488 b is best after 17 digits -------------------------------------------------- Note: On another machine I have seen a failure for i=216, but only in 32-bit mode. There might be hardware dependencies here. $ grep Intel /proc/cpuinfo | head -2 vendor_id : GenuineIntel model name : Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz $ grep PRETTY /etc/os-release PRETTY_NAME="Linux Mint 20.2" I believe I am using libc version 2.31-0ubuntu9.2cross1 Compilation: $ gcc -v -g -Wall -O2 eee.c -lm Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/9/lto-wrapper OFFLOAD_TARGET_NAMES=nvptx-none:hsa OFFLOAD_TARGET_DEFAULT=1 Target: x86_64-linux-gnu Configured with: ../src/configure -v --with-pkgversion='Ubuntu 9.3.0-17ubuntu1~20.04' --with-bugurl=file:///usr/share/doc/gcc-9/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++,gm2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-9 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-plugin --enable-default-pie --with-system-zlib --with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none=/build/gcc-9-HskZEa/gcc-9-9.3.0/debian/tmp-nvptx/usr,hsa --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu Thread model: posix gcc version 9.3.0 (Ubuntu 9.3.0-17ubuntu1~20.04) COLLECT_GCC_OPTIONS='-v' '-g' '-Wall' '-O2' '-mtune=generic' '-march=x86-64' /usr/lib/gcc/x86_64-linux-gnu/9/cc1 -quiet -v -imultiarch x86_64-linux-gnu eee.c -quiet -dumpbase eee.c -mtune=generic -march=x86-64 -auxbase eee -g -O2 -Wall -version -fasynchronous-unwind-tables -fstack-protector-strong -Wformat-security -fstack-clash-protection -fcf-protection -o /tmp/ccbP42NQ.s GNU C17 (Ubuntu 9.3.0-17ubuntu1~20.04) version 9.3.0 (x86_64-linux-gnu) compiled by GNU C version 9.3.0, GMP version 6.2.0, MPFR version 4.0.2, MPC version 1.1.0, isl version isl-0.22.1-GMP GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 ignoring nonexistent directory "/usr/local/include/x86_64-linux-gnu" ignoring nonexistent directory "/usr/lib/gcc/x86_64-linux-gnu/9/include-fixed" ignoring nonexistent directory "/usr/lib/gcc/x86_64-linux-gnu/9/../../../../x86_64-linux-gnu/include" #include "..." search starts here: #include <...> search starts here: /usr/lib/gcc/x86_64-linux-gnu/9/include /usr/local/include /usr/include/x86_64-linux-gnu /usr/include End of search list. GNU C17 (Ubuntu 9.3.0-17ubuntu1~20.04) version 9.3.0 (x86_64-linux-gnu) compiled by GNU C version 9.3.0, GMP version 6.2.0, MPFR version 4.0.2, MPC version 1.1.0, isl version isl-0.22.1-GMP GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 Compiler executable checksum: bbf13931d8de1abe14040c9909cb6969 COLLECT_GCC_OPTIONS='-v' '-g' '-Wall' '-O2' '-mtune=generic' '-march=x86-64' as -v --64 -o /tmp/ccSWUKiU.o /tmp/ccbP42NQ.s GNU assembler version 2.34 (x86_64-linux-gnu) using BFD version (GNU Binutils for Ubuntu) 2.34 COMPILER_PATH=/usr/lib/gcc/x86_64-linux-gnu/9/:/usr/lib/gcc/x86_64-linux-gnu/9/:/usr/lib/gcc/x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/9/:/usr/lib/gcc/x86_64-linux-gnu/ LIBRARY_PATH=/usr/lib/gcc/x86_64-linux-gnu/9/:/usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/9/../../../../lib/:/lib/x86_64-linux-gnu/:/lib/../lib/:/usr/lib/x86_64-linux-gnu/:/usr/lib/../lib/:/usr/lib/gcc/x86_64-linux-gnu/9/../../../:/lib/:/usr/lib/ COLLECT_GCC_OPTIONS='-v' '-g' '-Wall' '-O2' '-mtune=generic' '-march=x86-64' /usr/lib/gcc/x86_64-linux-gnu/9/collect2 -plugin /usr/lib/gcc/x86_64-linux-gnu/9/liblto_plugin.so -plugin-opt=/usr/lib/gcc/x86_64-linux-gnu/9/lto-wrapper -plugin-opt=-fresolution=/tmp/ccMHqq8T.res -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lc -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s --build-id --eh-frame-hdr -m elf_x86_64 --hash-style=gnu --as-needed -dynamic-linker /lib64/ld-linux-x86-64.so.2 -pie -z now -z relro /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/crti.o /usr/lib/gcc/x86_64-linux-gnu/9/crtbeginS.o -L/usr/lib/gcc/x86_64-linux-gnu/9 -L/usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu -L/usr/lib/gcc/x86_64-linux-gnu/9/../../../../lib -L/lib/x86_64-linux-gnu -L/lib/../lib -L/usr/lib/x86_64-linux-gnu -L/usr/lib/../lib -L/usr/lib/gcc/x86_64-linux-gnu/9/../../.. /tmp/ccSWUKiU.o -lm -lgcc --push-state --as-needed -lgcc_s --pop-state -lc -lgcc --push-state --as-needed -lgcc_s --pop-state /usr/lib/gcc/x86_64-linux-gnu/9/crtendS.o /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/crtn.o COLLECT_GCC_OPTIONS='-v' '-g' '-Wall' '-O2' '-mtune=generic' '-march=x86-64' -- You are receiving this mail because: You are on the CC list for the bug.
next reply other threads:[~2021-10-18 23:54 UTC|newest] Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-10-18 23:54 mwelinder at gmail dot com [this message] 2021-10-19 15:44 ` [Bug math/28472] " joseph at codesourcery dot com 2021-10-19 21:28 ` mwelinder at gmail dot com 2021-10-19 21:42 ` joseph at codesourcery dot com 2021-10-25 8:44 ` newbie-02 at gmx dot de 2021-11-14 5:38 ` newbie-02 at gmx dot de 2022-01-24 21:45 ` mwelinder at gmail dot com 2022-01-24 21:56 ` joseph at codesourcery dot com 2022-09-23 16:33 ` newbie-02 at gmx dot de 2023-01-09 14:43 ` newbie-02 at gmx dot de 2023-01-09 18:35 ` joseph at codesourcery dot com 2023-01-09 21:23 ` newbie-02 at gmx dot de 2023-01-09 21:36 ` joseph at codesourcery dot com 2023-01-10 0:23 ` newbie-02 at gmx dot de 2024-03-02 22:53 ` vincent-srcware at vinc17 dot net 2024-03-04 14:58 ` wdijkstr at arm dot com 2024-03-04 15:35 ` vincent-srcware at vinc17 dot net 2024-03-04 16:07 ` wdijkstr at arm dot com 2024-03-04 17:09 ` vincent-srcware at vinc17 dot net 2024-03-04 18:27 ` wdijkstr at arm dot com 2024-03-04 19:23 ` vincent-srcware at vinc17 dot net 2024-03-18 21:09 ` newbie-02 at gmx dot de 2024-03-18 22:17 ` wdijkstr at arm dot com 2024-03-20 9:02 ` newbie-02 at gmx dot de 2024-03-20 9:56 ` vincent-srcware at vinc17 dot net 2024-03-20 13:54 ` wdijkstr at arm dot com
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-28472-131@http.sourceware.org/bugzilla/ \ --to=sourceware-bugzilla@sourceware.org \ --cc=glibc-bugs@sourceware.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).