|
1 | | -// Copyright 2024 Matt Borland |
| 1 | +// Copyright 2024 - 2025 Matt Borland |
| 2 | +// Copyright 2024 - 2025 Christopher Kormanyos |
2 | 3 | // Distributed under the Boost Software License, Version 1.0. |
3 | 4 | // https://www.boost.org/LICENSE_1_0.txt |
4 | 5 |
|
@@ -137,6 +138,40 @@ void print_value(T value, const char* str) |
137 | 138 | << "\nExp: " << ptr << "\n" << std::endl; |
138 | 139 | } |
139 | 140 |
|
| 141 | +template<typename T> |
| 142 | +auto test_asin_edge() -> void |
| 143 | +{ |
| 144 | + using nl = std::numeric_limits<T>; |
| 145 | + |
| 146 | + const T tiny0 { nl::epsilon() * 999 / 1000 }; |
| 147 | + const T tiny1 { nl::epsilon() }; |
| 148 | + const T tiny2 { nl::epsilon() * 1000 / 999 }; |
| 149 | + |
| 150 | + const T asin_tiny0 { asin(tiny0) }; |
| 151 | + const T asin_tiny1 { asin(tiny1) }; |
| 152 | + const T asin_tiny2 { asin(tiny2) }; |
| 153 | + |
| 154 | + // tiny1: 1 |
| 155 | + // tiny2: 1.001001 |
| 156 | + // tiny0: 0.999 |
| 157 | + // tiny1: 1 |
| 158 | + // tiny2: 1.001001001001001 |
| 159 | + // tiny0: 0.999 |
| 160 | + // tiny1: 1 |
| 161 | + // tiny2: 1.001001001001001001001001001001001 |
| 162 | + |
| 163 | + constexpr T ctrl_tiny2 |
| 164 | + { |
| 165 | + std::numeric_limits<T>::digits10 < 10 ? T("1.001001") |
| 166 | + : std::numeric_limits<T>::digits10 < 20 ? T("1.001001001001001") |
| 167 | + : T("1.001001001001001001001001001001001") |
| 168 | + }; |
| 169 | + |
| 170 | + BOOST_TEST_EQ(asin_tiny0 / nl::epsilon(), T(999, -3)); |
| 171 | + BOOST_TEST_EQ(asin_tiny1 / nl::epsilon(), T(1)); |
| 172 | + BOOST_TEST_EQ(asin_tiny2 / nl::epsilon(), ctrl_tiny2); |
| 173 | +} |
| 174 | + |
140 | 175 | int main() |
141 | 176 | { |
142 | 177 | #ifdef BOOST_DECIMAL_GENERATE_CONSTANT_SIGS |
@@ -188,6 +223,10 @@ int main() |
188 | 223 | test_asin<decimal32_t>(); |
189 | 224 | test_asin<decimal64_t>(); |
190 | 225 |
|
| 226 | + test_asin_edge<decimal32_t>(); |
| 227 | + test_asin_edge<decimal64_t>(); |
| 228 | + test_asin_edge<decimal128_t>(); |
| 229 | + |
191 | 230 | #if !defined(BOOST_DECIMAL_REDUCE_TEST_DEPTH) |
192 | 231 | test_asin<decimal128_t>(); |
193 | 232 | #endif |
|
0 commit comments