MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / extract_double

Method extract_double

extern/boost/boost/multiprecision/cpp_dec_float.hpp:1567–1603  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1565
1566template <unsigned Digits10, class ExponentType, class Allocator>
1567double cpp_dec_float<Digits10, ExponentType, Allocator>::extract_double() const
1568{
1569 // Returns the double conversion of a cpp_dec_float<Digits10, ExponentType, Allocator>.
1570
1571 // Check for non-normal cpp_dec_float<Digits10, ExponentType, Allocator>.
1572 if (!(isfinite)())
1573 {
1574 if ((isnan)())
1575 {
1576 return std::numeric_limits<double>::quiet_NaN();
1577 }
1578 else
1579 {
1580 return ((!neg) ? std::numeric_limits<double>::infinity()
1581 : -std::numeric_limits<double>::infinity());
1582 }
1583 }
1584
1585 cpp_dec_float<Digits10, ExponentType, Allocator> xx(*this);
1586 if (xx.isneg())
1587 xx.negate();
1588
1589 // Check if *this cpp_dec_float<Digits10, ExponentType, Allocator> is zero.
1590 if (iszero() || (xx.compare(double_min()) < 0))
1591 {
1592 return 0.0;
1593 }
1594
1595 // Check if *this cpp_dec_float<Digits10, ExponentType, Allocator> exceeds the maximum of double.
1596 if (xx.compare(double_max()) > 0)
1597 {
1598 return ((!neg) ? std::numeric_limits<double>::infinity()
1599 : -std::numeric_limits<double>::infinity());
1600 }
1601
1602 return std::strtod(str(std::numeric_limits<double>::digits10 + (2 + 1), std::ios_base::scientific).c_str(), nullptr);
1603}
1604
1605template <unsigned Digits10, class ExponentType, class Allocator>
1606long double cpp_dec_float<Digits10, ExponentType, Allocator>::extract_long_double() const

Callers 1

eval_convert_toFunction · 0.80

Calls 5

isnegMethod · 0.80
strFunction · 0.70
negateMethod · 0.45
compareMethod · 0.45
c_strMethod · 0.45

Tested by

no test coverage detected