Skip to content

Commit

Permalink
Merge pull request #698 from cppalliance/develop
Browse files Browse the repository at this point in the history
Merge to master for 2.1.0
  • Loading branch information
mborland authored Jul 3, 2024
2 parents 6d088b3 + 2c81047 commit 3976725
Show file tree
Hide file tree
Showing 81 changed files with 4,552 additions and 2,167 deletions.
1 change: 1 addition & 0 deletions .drone.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ local linux_pipeline(name, image, environment, packages = "", sources = [], arch
{
name: "everything",
image: image,
privileged: true,
environment: environment,
commands:
[
Expand Down
4 changes: 4 additions & 0 deletions .drone/drone.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,9 @@ python tools/boostdep/depinst/depinst.py -I example $LIBRARY
./bootstrap.sh
./b2 -d0 headers

if [[ $(uname) == "Linux" ]]; then
echo 0 | sudo tee /proc/sys/kernel/randomize_va_space
fi

echo "using $TOOLSET : : $COMPILER ;" > ~/user-config.jam
./b2 -j3 libs/$LIBRARY/test toolset=$TOOLSET cxxstd=$CXXSTD variant=debug,release ${ADDRMD:+address-model=$ADDRMD} ${UBSAN:+undefined-sanitizer=norecover debug-symbols=on} ${ASAN:+address-sanitizer=norecover debug-symbols=on} ${CXXFLAGS:+cxxflags=$CXXFLAGS} ${CXXSTDDIALECT:+cxxstd-dialect=$CXXSTDDIALECT} ${LINKFLAGS:+linkflags=$LINKFLAGS}
9 changes: 5 additions & 4 deletions .github/workflows/codecov.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# ------------------------------------------------------------------------------
# Copyright Matt Borland 2023.
# Copyright Christopher Kormanyos 2023.
# Copyright Matt Borland 2023 - 2024.
# Copyright Christopher Kormanyos 2023 - 2024.
# Distributed under the Boost Software License,
# Version 1.0. (See accompanying file LICENSE_1_0.txt
# or copy at http://www.boost.org/LICENSE_1_0.txt)
Expand Down Expand Up @@ -66,7 +66,8 @@ jobs:
- name: upload-codecov
uses: codecov/codecov-action@v4
with:
files: ./test/cover/coverage.info
plugin: gcov
file: ${{ runner.workspace }}/decimal/test/cover/coverage.info
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: true
functionalities: fix
verbose: false
50 changes: 33 additions & 17 deletions include/boost/decimal/charconv.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ namespace detail {
template <BOOST_DECIMAL_DECIMAL_FLOATING_TYPE TargetDecimalType>
constexpr auto from_chars_general_impl(const char* first, const char* last, TargetDecimalType& value, chars_format fmt) noexcept -> from_chars_result
{
using significand_type = std::conditional_t<std::is_same<TargetDecimalType, decimal128>::value, detail::uint128, std::uint64_t>;
using significand_type = std::conditional_t<std::is_same<TargetDecimalType, decimal128>::value ||
std::is_same<TargetDecimalType, decimal128_fast>::value, detail::uint128, std::uint64_t>;

if (first >= last)
{
Expand Down Expand Up @@ -714,6 +715,11 @@ BOOST_DECIMAL_CONSTEXPR auto to_chars_hex_impl(char* first, char* last, const Ta
return to_chars_integer_impl<std::uint32_t, std::uint32_t>(first, last, static_cast<std::uint32_t>(abs_exp), 10);
}

#ifdef _MSC_VER
# pragma warning(push)
# pragma warning(disable: 4702) // Unreachable code
#endif

template <BOOST_DECIMAL_DECIMAL_FLOATING_TYPE TargetDecimalType>
BOOST_DECIMAL_CONSTEXPR auto to_chars_impl(char* first, char* last, TargetDecimalType value, chars_format fmt = chars_format::general, int precision = -1) noexcept -> to_chars_result
{
Expand All @@ -730,28 +736,26 @@ BOOST_DECIMAL_CONSTEXPR auto to_chars_impl(char* first, char* last, TargetDecima

constexpr auto min_fractional_value = TargetDecimalType{1, -4};

if (fmt == chars_format::hex)
{
return to_chars_hex_impl(first, last, value, precision);
}

// Unspecified precision so we always go with the shortest representation
if (precision == -1)
{
if (fmt == chars_format::general || fmt == chars_format::fixed)
switch (fmt)
{
if (abs_value >= 1 && abs_value < max_fractional_value)
{
case chars_format::general:
if (abs_value >= 1 && abs_value < max_fractional_value)
{
return to_chars_fixed_impl(first, last, value, fmt, precision);
}
else
{
return to_chars_scientific_impl(first, last, value, fmt, precision);
}
case chars_format::fixed:
return to_chars_fixed_impl(first, last, value, fmt, precision);
}
else
{
case chars_format::scientific:
return to_chars_scientific_impl(first, last, value, fmt, precision);
}
}
else
{
return to_chars_scientific_impl(first, last, value, fmt, precision);
case chars_format::hex:
return to_chars_hex_impl(first, last, value, precision); // LCOV_EXCL_LINE unreachable
}
}
else
Expand All @@ -766,13 +770,25 @@ BOOST_DECIMAL_CONSTEXPR auto to_chars_impl(char* first, char* last, TargetDecima
{
return to_chars_fixed_impl(first, last, value, fmt, precision);
}
else if (fmt == chars_format::hex)
{
return to_chars_hex_impl(first, last, value, precision);
}
else
{
return to_chars_scientific_impl(first, last, value, fmt, precision);
}
}

// LCOV_EXCL_START
return to_chars_scientific_impl(first, last, value, fmt, precision);
// LCOV_EXCL_STOP
}

#ifdef _MSC_VER
# pragma warning(pop)
#endif

} //namespace detail

BOOST_DECIMAL_EXPORT BOOST_DECIMAL_CONSTEXPR auto to_chars(char* first, char* last, decimal32 value) noexcept -> to_chars_result
Expand Down
3 changes: 2 additions & 1 deletion include/boost/decimal/cmath.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
#include <boost/decimal/detail/cmath/ceil.hpp>
#include <boost/decimal/detail/cmath/cos.hpp>
#include <boost/decimal/detail/cmath/cosh.hpp>
#include <boost/decimal/detail/cmath/ellint_1.hpp>
#include <boost/decimal/detail/cmath/ellint_2.hpp>
#include <boost/decimal/detail/cmath/exp.hpp>
#include <boost/decimal/detail/cmath/exp2.hpp>
#include <boost/decimal/detail/cmath/expm1.hpp>
Expand Down Expand Up @@ -69,7 +71,6 @@
#include <boost/decimal/detail/cmath/assoc_laguerre.hpp>
#include <boost/decimal/detail/cmath/legendre.hpp>
#include <boost/decimal/detail/cmath/assoc_legendre.hpp>
#include <boost/decimal/detail/cmath/ellint_1.hpp>
#include <boost/decimal/detail/cmath/trunc_to.hpp>
#include <boost/decimal/detail/cmath/beta.hpp>
#include <boost/decimal/numbers.hpp>
Expand Down
10 changes: 5 additions & 5 deletions include/boost/decimal/cstdlib.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ inline auto strtod_impl(const char* str, char** endptr) noexcept -> TargetDecima
if (str == nullptr)
{
errno = EINVAL;
return std::numeric_limits<TargetDecimalType>::signaling_NaN();
return std::numeric_limits<TargetDecimalType>::quiet_NaN();
}

const auto str_length {std::strlen(str)};
Expand All @@ -106,7 +106,7 @@ inline auto strtod_impl(const char* str, char** endptr) noexcept -> TargetDecima
// Hard to get coverage on memory exhaustion
// LCOV_EXCL_START
errno = ENOMEM;
return std::numeric_limits<TargetDecimalType>::signaling_NaN();
return std::numeric_limits<TargetDecimalType>::quiet_NaN();
// LCOV_EXCL_STOP
}

Expand All @@ -126,7 +126,7 @@ inline auto wcstod_calculation(const wchar_t* str, wchar_t** endptr, char* buffe
if (BOOST_DECIMAL_UNLIKELY(val > 255))
{
// Character can not be converted
return std::numeric_limits<TargetDecimalType>::signaling_NaN();
return std::numeric_limits<TargetDecimalType>::quiet_NaN();
}

buffer[i] = static_cast<char>(val);
Expand All @@ -150,7 +150,7 @@ inline auto wcstod_impl(const wchar_t* str, wchar_t** endptr) noexcept -> Target
if (str == nullptr)
{
errno = EINVAL;
return std::numeric_limits<TargetDecimalType>::signaling_NaN();
return std::numeric_limits<TargetDecimalType>::quiet_NaN();
}

const auto str_length {detail::strlen(str)};
Expand All @@ -169,7 +169,7 @@ inline auto wcstod_impl(const wchar_t* str, wchar_t** endptr) noexcept -> Target
// Hard to get coverage on memory exhaustion
// LCOV_EXCL_START
errno = ENOMEM;
return std::numeric_limits<TargetDecimalType>::signaling_NaN();
return std::numeric_limits<TargetDecimalType>::quiet_NaN();
// LCOV_EXCL_STOP
}

Expand Down
Loading

0 comments on commit 3976725

Please sign in to comment.