Skip to content

Commit 7e4f35b

Browse files
authored
Merge pull request #28 from vargalabs/20-build-vendor-boost-decimal-float-v6.0.1
2 parents b02bd47 + b610c18 commit 7e4f35b

186 files changed

Lines changed: 50343 additions & 1 deletion

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

thirdparty/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@
44
# Contact: info@vargalabs.com
55

66
add_subdirectory(doctest)
7-
add_subdirectory(intel-decimal-float)
7+
add_subdirectory(intel-decimal-float)
8+
add_subdirectory(boost-decimal-float)
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# This file is part of the libdecimal project and is licensed under the MIT License.
2+
#
3+
# Copyright © 2025–2026 Varga Labs, Toronto, ON, Canada 🇨🇦
4+
# Contact: info@vargalabs.com
5+
6+
set(name boostdecimal)
7+
8+
set(libname lib${name})
9+
project(${libname} LANGUAGES CXX)
10+
11+
set(current_version_dir "v6.0.1")
12+
add_library(${libname} INTERFACE)
13+
target_include_directories(${libname} INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/${current_version_dir}/include)
14+
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
Boost Software License - Version 1.0 - August 17th, 2003
2+
3+
Permission is hereby granted, free of charge, to any person or organization
4+
obtaining a copy of the software and accompanying documentation covered by
5+
this license (the "Software") to use, reproduce, display, distribute,
6+
execute, and transmit the Software, and to prepare derivative works of the
7+
Software, and to permit third-parties to whom the Software is furnished to
8+
do so, all subject to the following:
9+
10+
The copyright notices in the Software and this entire statement, including
11+
the above license grant, this restriction and the following disclaimer,
12+
must be included in all copies of the Software, in whole or in part, and
13+
all derivative works of the Software, unless such copies or derivative
14+
works are solely in the form of machine-executable object code generated by
15+
a source language processor.
16+
17+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19+
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
20+
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
21+
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
22+
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23+
DEALINGS IN THE SOFTWARE.
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
// Copyright 2023 Matt Borland
2+
// Distributed under the Boost Software License, Version 1.0.
3+
// https://www.boost.org/LICENSE_1_0.txt
4+
5+
#ifndef BOOST_DECIMAL_HPP
6+
#define BOOST_DECIMAL_HPP
7+
8+
// Clang-Cl likes to throw warnings everywhere for this
9+
// disable at the global level
10+
#if defined(__clang__) && !defined(__GNUC__)
11+
# pragma clang diagnostic push
12+
# pragma clang diagnostic ignored "-Wc++98-compat"
13+
# pragma clang diagnostic ignored "-Wc++98-compat-pedantic"
14+
#endif
15+
16+
// 3.4.7 evaluation format:
17+
// This is defined at top level because it has ramifications for every successive header
18+
#ifndef BOOST_DECIMAL_DEC_EVAL_METHOD
19+
# define BOOST_DECIMAL_DEC_EVAL_METHOD 0
20+
#endif
21+
22+
#if BOOST_DECIMAL_DEC_EVAL_METHOD < 0 || BOOST_DECIMAL_DEC_EVAL_METHOD > 2
23+
# error "Unsupported value of BOOST_DECIMAL_DEC_EVAL_METHOD. Must be 0, 1, or 2"
24+
#endif
25+
26+
#include <boost/decimal/fwd.hpp> // NOLINT(llvm-include-order)
27+
#include <boost/decimal/decimal32_t.hpp>
28+
#include <boost/decimal/decimal_fast32_t.hpp>
29+
#include <boost/decimal/decimal64_t.hpp>
30+
#include <boost/decimal/decimal_fast64_t.hpp>
31+
#include <boost/decimal/decimal128_t.hpp>
32+
#include <boost/decimal/decimal_fast128_t.hpp>
33+
#include <boost/decimal/cmath.hpp>
34+
#include <boost/decimal/cstdlib.hpp>
35+
#include <boost/decimal/cfenv.hpp>
36+
#include <boost/decimal/literals.hpp>
37+
#include <boost/decimal/hash.hpp>
38+
#include <boost/decimal/cfloat.hpp>
39+
#include <boost/decimal/charconv.hpp>
40+
#include <boost/decimal/iostream.hpp>
41+
#include <boost/decimal/format.hpp>
42+
#include <boost/decimal/cstdio.hpp>
43+
#include <boost/decimal/bid_conversion.hpp>
44+
#include <boost/decimal/dpd_conversion.hpp>
45+
#include <boost/decimal/string.hpp>
46+
#include <boost/decimal/uint128_t.hpp>
47+
48+
#if defined(__clang__) && !defined(__GNUC__)
49+
# pragma clang diagnostic pop
50+
#endif
51+
52+
#endif // BOOST_DECIMAL_HPP
Lines changed: 193 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,193 @@
1+
// Copyright 2024 Matt Borland
2+
// Distributed under the Boost Software License, Version 1.0.
3+
// https://www.boost.org/LICENSE_1_0.txt
4+
5+
#ifndef BOOST_DECIMAL_BID_CONVERSION_HPP
6+
#define BOOST_DECIMAL_BID_CONVERSION_HPP
7+
8+
#include <boost/decimal/decimal32_t.hpp>
9+
#include <boost/decimal/decimal64_t.hpp>
10+
#include <boost/decimal/decimal128_t.hpp>
11+
#include <boost/decimal/decimal_fast32_t.hpp>
12+
#include <boost/decimal/decimal_fast64_t.hpp>
13+
#include <boost/decimal/decimal_fast128_t.hpp>
14+
#include <boost/decimal/charconv.hpp>
15+
#include <boost/decimal/detail/concepts.hpp>
16+
#include "detail/int128.hpp"
17+
18+
namespace boost {
19+
namespace decimal {
20+
21+
#if defined(__GNUC__) && __GNUC__ == 7
22+
# pragma GCC diagnostic push
23+
# pragma GCC diagnostic ignored "-Wconversion"
24+
#endif
25+
26+
BOOST_DECIMAL_EXPORT constexpr auto to_bid_d32(const decimal32_t val) noexcept -> std::uint32_t
27+
{
28+
return val.bits_;
29+
}
30+
31+
BOOST_DECIMAL_EXPORT constexpr auto from_bid_d32(const std::uint32_t bits) noexcept -> decimal32_t
32+
{
33+
return from_bits(bits);
34+
}
35+
36+
BOOST_DECIMAL_EXPORT constexpr auto to_bid_d32f(const decimal_fast32_t val) noexcept -> std::uint32_t
37+
{
38+
const decimal32_t compliant_val {val};
39+
return to_bid_d32(compliant_val);
40+
}
41+
42+
BOOST_DECIMAL_EXPORT constexpr auto from_bid_d32f(const std::uint32_t bits) noexcept -> decimal_fast32_t
43+
{
44+
const auto compliant_val {from_bid_d32(bits)};
45+
const decimal_fast32_t val {compliant_val};
46+
return val;
47+
}
48+
49+
BOOST_DECIMAL_EXPORT constexpr auto to_bid_d64(const decimal64_t val) noexcept -> std::uint64_t
50+
{
51+
return val.bits_;
52+
}
53+
54+
BOOST_DECIMAL_EXPORT constexpr auto from_bid_d64(const std::uint64_t bits) noexcept -> decimal64_t
55+
{
56+
return from_bits(bits);
57+
}
58+
59+
BOOST_DECIMAL_EXPORT constexpr auto to_bid_d64f(const decimal_fast64_t val) noexcept -> std::uint64_t
60+
{
61+
const decimal64_t compliant_val {val};
62+
return to_bid_d64(compliant_val);
63+
}
64+
65+
BOOST_DECIMAL_EXPORT constexpr auto from_bid_d64f(const std::uint64_t bits) noexcept -> decimal_fast64_t
66+
{
67+
const auto compliant_val {from_bid_d64(bits)};
68+
const decimal_fast64_t val {compliant_val};
69+
return val;
70+
}
71+
72+
BOOST_DECIMAL_EXPORT constexpr auto to_bid_d128(const decimal128_t val) noexcept -> int128::uint128_t
73+
{
74+
return val.bits_;
75+
}
76+
77+
BOOST_DECIMAL_EXPORT constexpr auto from_bid_d128(const int128::uint128_t bits) noexcept -> decimal128_t
78+
{
79+
return from_bits(bits);
80+
}
81+
82+
#ifdef BOOST_DECIMAL_HAS_INT128
83+
BOOST_DECIMAL_EXPORT constexpr auto from_bid_d128(const detail::builtin_uint128_t bits) noexcept -> decimal128_t
84+
{
85+
return from_bits(bits);
86+
}
87+
#endif
88+
89+
BOOST_DECIMAL_EXPORT constexpr auto to_bid_d128f(const decimal_fast128_t& val) noexcept -> int128::uint128_t
90+
{
91+
const decimal128_t compliant_val {val};
92+
return to_bid_d128(compliant_val);
93+
}
94+
95+
BOOST_DECIMAL_EXPORT constexpr auto from_bid_d128f(const int128::uint128_t bits) noexcept -> decimal_fast128_t
96+
{
97+
const auto compliant_val {from_bid_d128(bits)};
98+
const decimal_fast128_t val {compliant_val};
99+
return val;
100+
}
101+
102+
#ifdef BOOST_DECIMAL_HAS_INT128
103+
BOOST_DECIMAL_EXPORT constexpr auto from_bid_d128f(const detail::builtin_uint128_t bits) noexcept -> decimal_fast128_t
104+
{
105+
const auto compliant_val {from_bid_d128(bits)};
106+
const decimal_fast128_t val {compliant_val};
107+
return val;
108+
}
109+
#endif
110+
111+
BOOST_DECIMAL_EXPORT constexpr auto to_bid(const decimal32_t val) noexcept -> std::uint32_t
112+
{
113+
return to_bid_d32(val);
114+
}
115+
116+
BOOST_DECIMAL_EXPORT constexpr auto to_bid(const decimal_fast32_t val) noexcept -> std::uint32_t
117+
{
118+
return to_bid_d32f(val);
119+
}
120+
121+
BOOST_DECIMAL_EXPORT constexpr auto to_bid(const decimal64_t val) noexcept -> std::uint64_t
122+
{
123+
return to_bid_d64(val);
124+
}
125+
126+
BOOST_DECIMAL_EXPORT constexpr auto to_bid(const decimal_fast64_t val) noexcept -> std::uint64_t
127+
{
128+
return to_bid_d64f(val);
129+
}
130+
131+
BOOST_DECIMAL_EXPORT constexpr auto to_bid(const decimal128_t val) noexcept -> int128::uint128_t
132+
{
133+
return to_bid_d128(val);
134+
}
135+
136+
BOOST_DECIMAL_EXPORT constexpr auto to_bid(const decimal_fast128_t& val) noexcept -> int128::uint128_t
137+
{
138+
return to_bid_d128f(val);
139+
}
140+
141+
BOOST_DECIMAL_EXPORT template <typename T>
142+
constexpr auto to_bid(const T val) noexcept
143+
{
144+
return to_bid(val);
145+
}
146+
147+
BOOST_DECIMAL_EXPORT template <typename T = decimal32_t>
148+
constexpr auto from_bid(const std::uint32_t bits) noexcept
149+
BOOST_DECIMAL_REQUIRES(detail::is_decimal_floating_point_v, T)
150+
{
151+
return from_bid_d32(bits);
152+
}
153+
154+
template <>
155+
constexpr auto from_bid<decimal_fast32_t>(const std::uint32_t bits) noexcept -> decimal_fast32_t
156+
{
157+
return from_bid_d32f(bits);
158+
}
159+
160+
BOOST_DECIMAL_EXPORT template <typename T = decimal64_t>
161+
constexpr auto from_bid(const std::uint64_t bits) noexcept
162+
BOOST_DECIMAL_REQUIRES(detail::is_decimal_floating_point_v, T)
163+
{
164+
return from_bid_d64(bits);
165+
}
166+
167+
template <>
168+
constexpr auto from_bid<decimal_fast64_t>(const std::uint64_t bits) noexcept -> decimal_fast64_t
169+
{
170+
return from_bid_d64f(bits);
171+
}
172+
173+
BOOST_DECIMAL_EXPORT template <typename T = decimal128_t>
174+
constexpr auto from_bid(const int128::uint128_t bits) noexcept
175+
BOOST_DECIMAL_REQUIRES(detail::is_decimal_floating_point_v, T)
176+
{
177+
return from_bid_d128(bits);
178+
}
179+
180+
template <>
181+
constexpr auto from_bid<decimal_fast128_t>(const int128::uint128_t bits) noexcept -> decimal_fast128_t
182+
{
183+
return from_bid_d128f(bits);
184+
}
185+
186+
#if defined(__GNUC__) && __GNUC__ == 7
187+
# pragma GCC diagnostic pop
188+
#endif
189+
190+
} // namespace decimal
191+
} // namespace boost
192+
193+
#endif //BOOST_BID_CONVERSION_HPP

0 commit comments

Comments
 (0)