I get the NA Digest newsletter, and a recent issue (NA Digest Sunday, February 24, 2008 Volume 08 : Issue 08) has an article about problems with cosine calculations on some 64 bit Linux environments, and I'm wondering if any Monks have seen this sort of behavior in Perl. I've attached a copy of the article:

From: Tomonori Kouya <> Date: Sun, 17 Feb 2008 20:45:30 -0500 Subject: Strange Phenomenon of Cosine Function on Linux x86_64 env Dear NA digest subscribers, I am in trouble about the problem on cosine function in IEEE754 double precision. On Fedora Core 4/8 or CentOS 4/5 x86_64 + gcc 4 env, I ran +the program which included the functions below in 4 different rounding-mod +es (RN, RZ, RP, RM) in order to know amount of round-off error. current_rmode = fegetround(); // get current rounding mode fesetround(rmode); // change rounding mode ret = cos(x); // cosine function fesetround(current_rmode); // restore rounding mode As a result, very different values of cosine func are obtained like: cos( 5.04710873550435011e+01) = RN, RZ: 9.78937668119415738e-01, 9.78937668119415627e-01 RP, RM: 5.55012195441045186e-01, 9.78937668119415627e-01 ^^^^^^^^^^^^^^^^^^^^^^^ incorrect! In the RN mode, the cosine function always returns correct values, but + often incorrect and very different values in other 3 modes. If you want to c +heck this phenomenon on your env, you can download my sample program from http://na-inet.jp/weblog/archives/test_cos.c. By trying to run the abo +ve "test_cos.c" on 32bit and 64bit Linux environments around me, this phe +nomenon could not be found in 32bit env such as Pentium 3/4 and in Mac OS X 10 +.4 + Xcode + Core2Duo. I will appreciate your sending the information about this problem. Sincerely yours, Tomonori KOUYA <>

Note that I am not Tomonori Kouya, which is why I've removed his (her?) email address.

Apparently, this question is spreading far: it's shown up in comp.lang.fortran.


emc

Information about American English usage here and here.

Floating point issues? Read this before posting: http://docs.sun.com/source/806-3568/ncg_goldberg.html


In reply to Strange Phenomenon of Cosine Function on Linux x86_64 env by swampyankee

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.