Skip to content

Cover the rest of the sin, cos and tan reduction - #1481

Merged
ckormanyos merged 1 commit into
boostorg:developfrom
ibmibmibm:trig-coverage
Oct 1, 2026
Merged

ckormanyos merged 1 commit into
boostorg:developfrom
ibmibmibm:trig-coverage

Conversation

@ibmibmibm

Copy link
Copy Markdown
Contributor

Summary

This PR is a follow-up to #1475. It adds two test points for sin, cos and tan, and it removes three branches of the reduction that no input can reach.

New tests
  • test_trig_rounding now tests -10^19. This value uses the reduction with base-1e9 words for a negative argument.
  • test_trig_rounding now tests 10^-80. For an argument this small, fx_from gives 0, and the kernel uses the argument as the result.
Removed branches
  • to_words for a 128-bit significand now always returns 4 words. frexp10 gives 34 digits, thus the high word is never zero. Zero high words do not change the product.
  • The decimal and binary reductions do not test for a zero fraction. The worst cases have at most 37 leading zero digits and 117 leading zero bits, thus the fraction is never zero. A comment at each loop gives these limits.
Tests

GCC 16.2.1 and Clang 22.1.8, C++14 and C++20, with -Wall -Wextra -Werror -Wconversion -Wsign-conversion -Wshadow -Wundef: test_trig_rounding, test_sin_cos, test_tan, test_cmath and test_fenv pass.

- test_trig_rounding now tests -10^19, which uses the reduction with
  base-1e9 words for a negative x.
- test_trig_rounding now tests 10^-80. For such a small x, fx_from
  gives 0 and the kernel uses x as the result.
- to_words for a 128-bit significand returns 4 words. frexp10 gives 34
  digits, thus the high word is never zero. Zero high words do not
  change the product.
- The reduction does not test for a zero fraction. The worst cases have
  at most 37 leading zero digits and 117 leading zero bits, thus the
  fraction is never zero.
@codecov

codecov Bot commented Oct 1, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.7%. Comparing base (7c79789) to head (9c582c2).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff            @@
##           develop   #1481     +/-   ##
=========================================
+ Coverage     98.7%   98.7%   +0.1%     
=========================================
  Files          313     313             
  Lines        26252   26255      +3     
  Branches      2249    2246      -3     
=========================================
+ Hits         25897   25908     +11     
+ Misses         355     347      -8     
Files with missing lines Coverage Δ
...de/boost/decimal/detail/cmath/impl/trig_reduce.hpp 100.0% <100.0%> (+2.8%) ⬆️
test/test_trig_rounding.cpp 100.0% <100.0%> (ø)

... and 1 file with indirect coverage changes


Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7c79789...9c582c2. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ckormanyos
ckormanyos merged commit c52d0e2 into boostorg:develop Oct 1, 2026
75 checks passed
@ckormanyos

Copy link
Copy Markdown
Member

LGTM. Merging

@ibmibmibm
ibmibmibm deleted the trig-coverage branch October 1, 2026 16:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants