Bug 227179 - powl has lower than advertised precision
Summary: powl has lower than advertised precision
Status: New
Alias: None
Product: Base System
Classification: Unclassified
Component: misc (show other bugs)
Version: 11.0-STABLE
Hardware: Any Any
: --- Affects Only Me
Assignee: freebsd-numerics mailing list
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-04-01 16:04 UTC by Yuri Victorovich
Modified: 2019-01-10 03:24 UTC (History)
0 users

See Also:


Attachments
pow.cc (226 bytes, text/plain)
2018-04-01 16:04 UTC, Yuri Victorovich
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Yuri Victorovich freebsd_committer 2018-04-01 16:04:50 UTC
Created attachment 192060 [details]
pow.cc

powl produces inaccurate results.

The attached program prints different results, depending on it using powl or not.

In the unoptimized case, it used powl:
> $ c++ -o pow pow.cc  && pow
> /tmp/pow-a03910.o: In function `main':
> pow.cc:(.text+0x5b): warning: powl has lower than advertised precision
> pow(integer{2}, 4.5l) -> 22.627416997969518774880270939320
> std::pow(2.l, 4.5l) -> 22.627416997969518774880270939320

In the optimized case, powl is pre-computed by the compiler:
> $ c++ -O3 -o pow pow.cc  && pow
> pow(integer{2}, 4.5l) -> 22.627416997969520780220609168509
> std::pow(2.l, 4.5l) -> 22.627416997969520780220609168509

The results are different.
Comment 1 Pedro F. Giffuni freebsd_committer 2019-01-10 03:24:12 UTC
Assign to -numerics.