This is the mail archive of the
libc-help@sourceware.org
mailing list for the glibc project.
Re: Interaction between rounding direction and trigonometric functions
- From: "Ryan Arnold" <ryan dot arnold at gmail dot com>
- To: "Peter Eberlein" <eberlein at us dot ibm dot com>
- Cc: libc-help at sourceware dot org, "Roberto Bagnara" <bagnara at cs dot unipr dot it>
- Date: Fri, 5 Sep 2008 13:43:34 -0500
- Subject: Re: Interaction between rounding direction and trigonometric functions
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:cc:in-reply-to:mime-version:content-type :content-transfer-encoding:content-disposition:references; bh=4+T5cbHwEcXGuVjgGr+oYYkzPimzpXS2Vrrqv3SB7HQ=; b=HSzjCx29UuDrWANHr1q1KP7A6Vu45XcNU9N+xqJihw6IFtJUBUAH0cXrT7qb0IIg7u YDUjvzmJn0i3ns74HYm7fnUYP7Omk3HrIvwk2tjZIoe9MyYHgBtXnElM1ZxvhGOyHkO4 pFZDR9ayF+s1BBw0lVI6gyhVtQU+lNZVYshz8=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:cc:in-reply-to:mime-version :content-type:content-transfer-encoding:content-disposition :references; b=YmwPA7Arl59cGWw7hUmXDtB26vOcK/rSC2yweA2JIY0/MJOBGvdJFaoJatQGpcQQq3 8ECVDLAnpzAtHTXFp/I9LwfJvWWkhaeMLyNvgJlbeOCw0CR5v3HgclyUQjdpmW4E6XUq fndnE8DUq2520Tb61rj3m8OR8A6dMJMiu6VHA=
- References: <48C16C86.80203@cs.unipr.it>
Peter Eberlein,
Did you address some issues in the GLIBC bugzilla regarding rounding direction?
On Fri, Sep 5, 2008 at 12:29 PM, Roberto Bagnara <bagnara@cs.unipr.it> wrote:
>
> Hi there,
>
> I have the following observation:
>
> $ cat bug2.cc
> #include <fenv.h>
> #include <iostream>
> #include <cmath>
>
> int main() {
> double theta = 5.27905511969922880410877041867934167385101318359375;
>
> std::cout << "theta = " << theta << "\n";
> std::cout << "sin(theta) = " << sin(theta) << "\n";
> std::cout << "cos(theta) = " << cos(theta) << "\n";
>
> std::cout << "Repeating after setting the rounding direction to UPWARD:"
> << std::endl;
>
> fesetround(FE_UPWARD);
> std::cout << "theta = " << theta << "\n";
> std::cout << "sin(theta) = " << sin(theta) << "\n";
> std::cout << "cos(theta) = " << cos(theta) << "\n";
> }
> $ g++ -W -Wall bug2.cc
> $ a.out
> theta = 5.27906
> sin(theta) = -0.843695
> cos(theta) = 0.536822
> Repeating after setting the rounding direction to UPWARD:
> theta = 5.27906
> sin(theta) = -0.119458
> cos(theta) = 12.1636
> $
>
> This happens on a Fedora 7, x86_64 system, with glibc-2.6-4
> and GCC 4.3.2.
>
> As you see, after setting the rounding direction to UPWARD,
> the results are grossly wrong, to the point of cos() returning
> 12.1636. I wonder if this is a bug or if I am using sin()
> and cos() outside their specification. I have checked
> the glibc manual, but I did not find anything allowing to
> answer this question.
> All the best,
>
> Roberto
>
> --
> Prof. Roberto Bagnara
> Computer Science Group
> Department of Mathematics, University of Parma, Italy
> http://www.cs.unipr.it/~bagnara/
> mailto:bagnara@cs.unipr.it
>
>
>
>