public inbox for glibc-bugs@sourceware.org help / color / mirror / Atom feed
From: "David dot Monniaux at ens dot fr" <sourceware-bugzilla@sources.redhat.com> To: glibc-bugs@sources.redhat.com Subject: [Bug libc/763] New: On AMD64 in IEEE round-to-plus-infinity (upward) mode, pow() may segfault and exp() yield negative results Date: Thu, 24 Feb 2005 17:19:00 -0000 [thread overview] Message-ID: <20050224171910.763.David.Monniaux@ens.fr> (raw) On AMD64, after a fesetround(FE_UPWARD), on certain values: - pow() issues a segmentation fault - exp() yields a negative result #include <math.h> #include <fenv.h> #include <stdio.h> int main() { double x = 79.252413924118542354335659183561801910400390625; double y = 0.333333299999999999041477849459624849259853363037109375; double z; fesetround(FE_UPWARD); z = pow(x,y); /* segfault my_log2 () */ return 0; } #include <math.h> #include <fenv.h> #include <stdio.h> int main() { double x = 79.252413924118542354335659183561801910400390625; double y = 0.333333299999999999041477849459624849259853363037109375; double z; double a = 10e18; double b = 1.0; fesetround(FE_UPWARD); z = exp(log(x)*y); printf("%lf %lf\n", (a+b)-a, z); /* second number output is -0.246008 */ return 0; } I note that ./sysdeps/ieee754/dbl-64/e_pow.c states "Assumption: Machine arithmetic operations are performed in round to nearest mode of IEEE 754 standard." Proposed fix: if glibc does not attempt to provide the nearest upward or downward result for pow() and exp() in non-nearest rounding modes, one can use the exp2() and log2() primitives. ex: pow(x, y) = exp2(log2(x) * y) -- Summary: On AMD64 in IEEE round-to-plus-infinity (upward) mode, pow() may segfault and exp() yield negative results Product: glibc Version: 2.3.3 Status: NEW Severity: normal Priority: P2 Component: libc AssignedTo: gotom at debian dot or dot jp ReportedBy: David dot Monniaux at ens dot fr CC: glibc-bugs at sources dot redhat dot com GCC build triplet: x86_64-unknown-linux-gnu GCC host triplet: x86_64-unknown-linux-gnu GCC target triplet: x86_64-unknown-linux-gnu http://sources.redhat.com/bugzilla/show_bug.cgi?id=763 ------- You are receiving this mail because: ------- You are on the CC list for the bug, or are watching someone who is.
next reply other threads:[~2005-02-24 17:19 UTC|newest] Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top 2005-02-24 17:19 David dot Monniaux at ens dot fr [this message] 2005-02-24 17:20 ` [Bug libc/763] " David dot Monniaux at ens dot fr 2005-02-24 17:21 ` David dot Monniaux at ens dot fr 2005-03-10 9:48 ` [Bug math/763] " gotom at debian dot or dot jp 2005-06-07 11:58 ` David dot Monniaux at ens dot fr 2005-09-16 12:29 ` aj at suse dot de
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=20050224171910.763.David.Monniaux@ens.fr \ --to=sourceware-bugzilla@sources.redhat.com \ --cc=glibc-bugs@sources.redhat.com \ /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).