@@ -1402,18 +1402,13 @@ constexpr void eval_fabs(cpp_double_fp_backend<FloatingPointType>& result, const
1402
1402
template <typename FloatingPointType>
1403
1403
constexpr void eval_frexp (cpp_double_fp_backend<FloatingPointType>& result, const cpp_double_fp_backend<FloatingPointType>& a, int * v)
1404
1404
{
1405
- #if 0
1406
- result.rep().first = cpp_df_qf_detail::ccmath::frexp(a.rep().first, v);
1407
- result.rep().second = cpp_df_qf_detail::ccmath::ldexp(a.rep().second, -*v);
1408
- #else
1409
1405
using local_backend_type = cpp_double_fp_backend<FloatingPointType>;
1410
1406
using local_float_type = typename local_backend_type::float_type;
1411
1407
1412
1408
const local_float_type fhi { cpp_df_qf_detail::ccmath::frexp (a.rep ().first , v) };
1413
1409
const local_float_type flo { cpp_df_qf_detail::ccmath::ldexp (a.rep ().second , -*v) };
1414
1410
1415
1411
local_backend_type::arithmetic::normalize (result.rep (), fhi, flo);
1416
- #endif
1417
1412
}
1418
1413
1419
1414
template <typename FloatingPointType>
@@ -1431,41 +1426,6 @@ constexpr void eval_ldexp(cpp_double_fp_backend<FloatingPointType>& result, cons
1431
1426
template <typename FloatingPointType>
1432
1427
constexpr void eval_floor (cpp_double_fp_backend<FloatingPointType>& result, const cpp_double_fp_backend<FloatingPointType>& x)
1433
1428
{
1434
- #if 0
1435
- using double_float_type = cpp_double_fp_backend<FloatingPointType>;
1436
-
1437
- const typename double_float_type::float_type fhi = cpp_df_qf_detail::floor_of_constituent(x.my_first());
1438
-
1439
- if (fhi != x.my_first())
1440
- {
1441
- result.rep().first = fhi;
1442
- result.rep().second = static_cast<typename double_float_type::float_type>(0.0F);
1443
- }
1444
- else
1445
- {
1446
- const bool is_fractional_lo { cpp_df_qf_detail::ccmath::fabs(x.my_second()) < 1 };
1447
- const bool is_negative_lo { x.my_second() < 0 };
1448
-
1449
- if (is_fractional_lo)
1450
- {
1451
- if (is_negative_lo)
1452
- {
1453
- result.rep().first = fhi - typename double_float_type::float_type { 1 };
1454
- result.rep().second = typename double_float_type::float_type { 0 };
1455
- }
1456
- else
1457
- {
1458
- result.rep().first = fhi;
1459
- result.rep().second = typename double_float_type::float_type { 0 };
1460
- }
1461
- }
1462
- else
1463
- {
1464
- result.rep().second = cpp_df_qf_detail::floor_of_constituent(x.my_second());
1465
- result.rep().second = fhi;
1466
- }
1467
- }
1468
- #else
1469
1429
using local_backend_type = cpp_double_fp_backend<FloatingPointType>;
1470
1430
using local_float_type = typename local_backend_type::float_type;
1471
1431
@@ -1482,7 +1442,6 @@ constexpr void eval_floor(cpp_double_fp_backend<FloatingPointType>& result, cons
1482
1442
1483
1443
local_backend_type::arithmetic::normalize (result.rep (), fhi, flo);
1484
1444
}
1485
- #endif
1486
1445
}
1487
1446
1488
1447
template <typename FloatingPointType>
@@ -1497,27 +1456,6 @@ constexpr void eval_ceil(cpp_double_fp_backend<FloatingPointType>& result, const
1497
1456
template <typename FloatingPointType>
1498
1457
constexpr int eval_fpclassify (const cpp_double_fp_backend<FloatingPointType>& o)
1499
1458
{
1500
- #if 0
1501
- const int fpc_a { cpp_df_qf_detail::ccmath::fpclassify(o.crep().first) };
1502
- const int fpc_b { cpp_df_qf_detail::ccmath::fpclassify(o.crep().second) };
1503
-
1504
- if ((fpc_a == FP_ZERO) && ((fpc_b == FP_ZERO) || (fpc_b == FP_SUBNORMAL)))
1505
- {
1506
- return FP_ZERO;
1507
- }
1508
- else
1509
- {
1510
- if ((fpc_a == FP_NORMAL) && (fpc_b == FP_SUBNORMAL))
1511
- {
1512
- return FP_SUBNORMAL;
1513
- }
1514
- else
1515
- {
1516
- return fpc_a;
1517
- }
1518
- }
1519
-
1520
- #else
1521
1459
using local_backend_type = cpp_double_fp_backend<FloatingPointType>;
1522
1460
using local_float_type = typename local_backend_type::float_type;
1523
1461
@@ -1528,7 +1466,6 @@ constexpr int eval_fpclassify(const cpp_double_fp_backend<FloatingPointType>& o)
1528
1466
: eval_is_zero (o) ? FP_ZERO
1529
1467
: ((fabs_x > 0 ) && (fabs_x < (cpp_df_qf_detail::ccmath::numeric_limits<FloatingPointType>::min)())) ? FP_SUBNORMAL
1530
1468
: FP_NORMAL;
1531
- #endif
1532
1469
}
1533
1470
1534
1471
template <typename FloatingPointType>
@@ -1560,13 +1497,15 @@ constexpr void eval_sqrt(cpp_double_fp_backend<FloatingPointType>& result, const
1560
1497
}
1561
1498
}
1562
1499
1563
- const local_float_type c = cpp_df_qf_detail::ccmath::sqrt (o. crep (). first );
1500
+ // TBD: Optimize this in a similar was as has been done for mul/div.
1564
1501
1565
- constexpr auto MantissaBits = cpp_df_qf_detail::ccmath::numeric_limits<local_float_type>::digits;
1566
- constexpr auto SplitBits = static_cast <int >((MantissaBits / 2 ) + 1 );
1567
- constexpr auto Splitter = static_cast <local_float_type>((1ULL << SplitBits) + 1 );
1502
+ // TBD: Taking the square root of a large number (like the (max)() value)
1503
+ // will overflow when multiplying by the split. Can this be handled
1504
+ // more graciously?
1505
+
1506
+ const local_float_type c = cpp_df_qf_detail::ccmath::sqrt (o.crep ().first );
1568
1507
1569
- local_float_type p = Splitter * c;
1508
+ local_float_type p = cpp_df_qf_detail::split ( local_float_type ()) * c;
1570
1509
local_float_type hx = (c - p);
1571
1510
hx = hx + p;
1572
1511
local_float_type tx = c - hx;
0 commit comments