Opened 6 years ago

Closed 6 years ago

#12581 closed Feature Requests (fixed)

cpp_bin_float: Anal fixation. Part 4. Special cases of atan2()

Reported by: Michael Shatz Owned by: John Maddock
Milestone: To Be Determined Component: multiprecision
Version: Boost 1.62.0 Severity: Cosmetic
Keywords: atan2 Cc:

Description

In following special cases boost::atan2(y, x) return values are different from C RTL:

  y     x  C RTL  boost
 inf  inf  pi/4   nan
-inf  inf -pi/4   nan
 inf -inf  3*pi/4 nan
-inf -inf -3*pi/4 nan
-0   -val -pi     pi
 0    nan  nan    0
 inf  nan  nan    pi/2
-inf  nan  nan   -pi/2

The first four boost answer make sense. IMHO, they are better than C RTL answers. The fifth boost answer is strange, but can be considered acceptable. The rest are plain bugs - nan should always propagate.

Attachments (1)

af_p4.cpp (1.4 KB ) - added by Michael Shatz 6 years ago.
demonstrates boost atan2() behavior that differs from C RTL

Download all attachments as: .zip

Change History (3)

by Michael Shatz, 6 years ago

Attachment: af_p4.cpp added

demonstrates boost atan2() behavior that differs from C RTL

comment:1 by John Maddock, 6 years ago

This is basically fixed in this giant commit which tries to bring all the functions into line with C99 annex F: https://github.com/boostorg/multiprecision/commit/138a9055e2edc68dca2e78ff97ffe6276c17fa0a

I might need to do some more work on this, especially for types other than cpp_bin_float.

comment:2 by John Maddock, 6 years ago

Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.