Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions doc/decimal/cmath.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -459,13 +459,13 @@ constexpr boost::decimal::detail::uint128 frexpd128(decimal128 num, int* expptr)
This function is very similar to https://en.cppreference.com/w/cpp/numeric/math/frexp[frexp], but returns the significand and an integral power of 10 since the `FLT_RADIX` of this type is 10.
The significand is normalized to the number of digits of precision the type has (e.g. for decimal32 it is [1'000'000, 9'999'999]).

=== trunc_to
=== rescale

[source, c++]
----
template <typename Decimal>
constexpr Decimal trunc_to(Decimal val, int precision = 0);
constexpr Decimal rescale(Decimal val, int precision = 0);
----

The function returns the decimal type with number of fractional digits equal to the value of precision.
`trunc_to` is similar to https://en.cppreference.com/w/cpp/numeric/math/trunc[trunc], and with the default precision argument of 0 it is identical.
`rescale` is similar to https://en.cppreference.com/w/cpp/numeric/math/trunc[trunc], and with the default precision argument of 0 it is identical.
2 changes: 1 addition & 1 deletion include/boost/decimal/cmath.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
#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/trunc_to.hpp>
#include <boost/decimal/detail/cmath/rescale.hpp>
#include <boost/decimal/detail/cmath/beta.hpp>
#include <boost/decimal/numbers.hpp>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// Copyright 2024 Matt Borland
// Copyright 2025 Matt Borland
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt

#ifndef BOOST_DECIMAL_DETAIL_CMATH_TRUNC_TO_HPP
#define BOOST_DECIMAL_DETAIL_CMATH_TRUNC_TO_HPP
#ifndef BOOST_DECIMAL_DETAIL_CMATH_RESCALE_HPP
#define BOOST_DECIMAL_DETAIL_CMATH_RESCALE_HPP

#include <boost/decimal/fwd.hpp>
#include <boost/decimal/detail/type_traits.hpp>
Expand All @@ -24,7 +24,7 @@ namespace boost {
namespace decimal {

BOOST_DECIMAL_EXPORT template <typename T>
constexpr auto trunc_to(T val, int precision = 0) noexcept
constexpr auto rescale(T val, int precision = 0) noexcept
BOOST_DECIMAL_REQUIRES(detail::is_decimal_floating_point_v, T)
{
constexpr auto biggest_val {1 / std::numeric_limits<T>::epsilon()};
Expand Down Expand Up @@ -64,8 +64,15 @@ constexpr auto trunc_to(T val, int precision = 0) noexcept
return {sig, exp, isneg};
}

BOOST_DECIMAL_EXPORT template <typename T>
[[deprecated("Renamed to rescale to match existing literature")]]
constexpr auto trunc_to(T val, int precision = 0) noexcept
BOOST_DECIMAL_REQUIRES(detail::is_decimal_floating_point_v, T)
{
return rescale(val, precision);
}

} // namespace decimal
} // namespace boost

#endif //BOOST_DECIMAL_DETAIL_CMATH_TRUNC_TO_HPP
#endif //BOOST_DECIMAL_DETAIL_CMATH_RESCALE_HPP
2 changes: 1 addition & 1 deletion test/cover/make_gcov_01_generic.gmk
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ gcov: objects
@$(GNUECHO)
@$(GNUECHO) +++ running lcov
@$(LCOV) $(LCOV_BRANCH) -c --directory obj --output-file coverage_unfiltered.info
@$(LCOV) $(LCOV_BRANCH) --remove coverage_unfiltered.info $(LCOV_REMOVES) --output-file coverage.info
@$(LCOV) $(LCOV_BRANCH) --remove coverage_unfiltered.info $(LCOV_REMOVES) --ignore-errors unused --output-file coverage.info
@$(GNUECHO)
@$(GNUECHO) +++ running genhtml
@$(GENHTML) coverage.info $(LCOV_BRANCH) --demangle-cpp --output-directory $(PATH_BIN)/report
Expand Down
3 changes: 2 additions & 1 deletion test/cover/make_gcov_03_flags.gmk
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ CXXFLAGS = -march=native \
-Wall \
-fno-inline-functions \
-fprofile-arcs \
-ftest-coverage
-ftest-coverage \
-std=$(STD)

C_DEFINES =

Expand Down
Loading
Loading