develooper Front page | perl.perl5.porters | Postings from August 2014

[perl #122571] sqrt() and sin() broken in AIX with long doubles

Thread Previous
From:
Jarkko Hietaniemi
Date:
August 20, 2014 03:26
Subject:
[perl #122571] sqrt() and sin() broken in AIX with long doubles
Message ID:
rt-4.0.18-23036-1408505176-400.122571-75-0@perl.org
# New Ticket Created by  Jarkko Hietaniemi 
# Please include the string:  [perl #122571]
# in the subject line of all future correspondence about this issue. 
# <URL: https://rt.perl.org/Ticket/Display.html?id=122571 >


(haven't been able to yet build a full perl (some weird env set up issues), but looks like AIX 6.1, have been able to buld miniperl)

If I configure with -Duselongdouble, sqrt() and sin() become quite oddly broken: sqrt() returns result twice too high:

./miniperl -le 'print sqrt(2)'
2.828427124746190290949243717478

(yeah, yeah, it *is* double the value - get it?)

and sin() returns just weird stuff:

0.3413235495583596401658610375307

(should be something like 0.841470984807897...)

Now, interestingly all of sin/cos/exp/log/sqrt are implemented by pp_sin (in pp.c).  But only the sqrt/sin seem to be broken, the cos/exp/log are seemingly not.

The plot thickens: the problem seems to be calling the functions (sqrtl, sinl) through function pointers (which is what pp_sin does).  I wrote a C test snippet which calls sqrtl(2.0L) directly, and it returns the expected 1.4142135623731... just fine.

I haven't yet looked into what is sqrtl(), really is, is it a real function with real code in -lm, or something else.

(These basic math functions are tested in t/op/exp.t, and yes, with results like this, the test fails)

So I guess there hasn't been much testing of AIX with long doubles.



Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About