Skip to content

Commit 67793ad

Browse files
authored
Merge pull request #585 from cppalliance/develop
Merge to Master for v1.2.0
2 parents b7b1ffa + d901dd4 commit 67793ad

Some content is hidden

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

79 files changed

+7056
-1474
lines changed

.drone.jsonnet

Lines changed: 36 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -98,17 +98,17 @@ local windows_pipeline(name, image, environment, arch = "amd64") =
9898
[
9999

100100
linux_pipeline(
101-
"Linux 23.04 GCC 13 GNU 32 ASAN",
102-
"cppalliance/droneubuntu2304:1",
103-
{ TOOLSET: 'gcc', COMPILER: 'g++-13', CXXSTD: '03,11,14,17,20,23', ADDRMD: '32', CXXFLAGS: "-fexcess-precision=fast", CXXSTDDIALECT: "gnu" } + asan,
104-
"g++-13-multilib",
101+
"Linux 24.04 GCC 14 GNU 32 ASAN",
102+
"cppalliance/droneubuntu2404:1",
103+
{ TOOLSET: 'gcc', COMPILER: 'g++-14', CXXSTD: '03,11,14,17,20,23', ADDRMD: '32', CXXFLAGS: "-fexcess-precision=fast", CXXSTDDIALECT: "gnu" } + asan,
104+
"g++-14-multilib",
105105
),
106106

107107
linux_pipeline(
108-
"Linux 23.04 GCC 13 GNU 64 ASAN",
109-
"cppalliance/droneubuntu2304:1",
110-
{ TOOLSET: 'gcc', COMPILER: 'g++-13', CXXSTD: '03,11,14,17,20,23', ADDRMD: '64', CXXFLAGS: "-fexcess-precision=fast", CXXSTDDIALECT: "gnu" } + asan,
111-
"g++-13-multilib",
108+
"Linux 24.04 GCC 14 GNU 64 ASAN",
109+
"cppalliance/droneubuntu2404:1",
110+
{ TOOLSET: 'gcc', COMPILER: 'g++-14', CXXSTD: '03,11,14,17,20,23', ADDRMD: '64', CXXFLAGS: "-fexcess-precision=fast", CXXSTDDIALECT: "gnu" } + asan,
111+
"g++-14-multilib",
112112
),
113113

114114
linux_pipeline(
@@ -173,19 +173,33 @@ local windows_pipeline(name, image, environment, arch = "amd64") =
173173
),
174174

175175
linux_pipeline(
176-
"Linux 23.04 GCC 13 32/64",
177-
"cppalliance/droneubuntu2304:1",
176+
"Linux 24.04 GCC 13 32/64",
177+
"cppalliance/droneubuntu2404:1",
178178
{ TOOLSET: 'gcc', COMPILER: 'g++-13', CXXSTD: '03,11,14,17,20,23', ADDRMD: '32,64', CXXFLAGS: "-fexcess-precision=fast" },
179179
"g++-13-multilib",
180180
),
181181

182182
linux_pipeline(
183-
"Linux 23.04 GCC 13 GNU 32/64",
184-
"cppalliance/droneubuntu2304:1",
183+
"Linux 24.04 GCC 13 GNU 32/64",
184+
"cppalliance/droneubuntu2404:1",
185185
{ TOOLSET: 'gcc', COMPILER: 'g++-13', CXXSTD: '03,11,14,17,20,23', ADDRMD: '32,64', CXXFLAGS: "-fexcess-precision=fast", CXXSTDDIALECT: "gnu" },
186186
"g++-13-multilib",
187187
),
188188

189+
linux_pipeline(
190+
"Linux 24.04 GCC 14 32/64",
191+
"cppalliance/droneubuntu2404:1",
192+
{ TOOLSET: 'gcc', COMPILER: 'g++-14', CXXSTD: '03,11,14,17,20,23', ADDRMD: '32,64', CXXFLAGS: "-fexcess-precision=fast" },
193+
"g++-14-multilib",
194+
),
195+
196+
linux_pipeline(
197+
"Linux 24.04 GCC 14 GNU 32/64",
198+
"cppalliance/droneubuntu2404:1",
199+
{ TOOLSET: 'gcc', COMPILER: 'g++-14', CXXSTD: '03,11,14,17,20,23', ADDRMD: '32,64', CXXFLAGS: "-fexcess-precision=fast", CXXSTDDIALECT: "gnu" },
200+
"g++-14-multilib",
201+
),
202+
189203
linux_pipeline(
190204
"Linux 18.04 GCC 7* 32 03",
191205
"cppalliance/droneubuntu1804:1",
@@ -329,13 +343,21 @@ local windows_pipeline(name, image, environment, arch = "amd64") =
329343
),
330344

331345
linux_pipeline(
332-
"Linux 23.10 Clang 17",
333-
"cppalliance/droneubuntu2310:1",
346+
"Linux 24.04 Clang 17",
347+
"cppalliance/droneubuntu2404:1",
334348
{ TOOLSET: 'clang', COMPILER: 'clang++-17', CXXSTD: '03,11,14,17,20,2b' },
335349
"clang-17",
336350
["deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-17 main"],
337351
),
338352

353+
linux_pipeline(
354+
"Linux 24.04 Clang 18",
355+
"cppalliance/droneubuntu2404:1",
356+
{ TOOLSET: 'clang', COMPILER: 'clang++-18', CXXSTD: '03,11,14,17,20,2b' },
357+
"clang-18",
358+
["deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-18 main"],
359+
),
360+
339361
macos_pipeline(
340362
"MacOS 10.15 Xcode 12.2 UBSAN",
341363
{ TOOLSET: 'clang', COMPILER: 'clang++', CXXSTD: '03,11,14,17,2a' } + ubsan,

.github/workflows/ci.yml

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,14 @@ jobs:
7777
os: ubuntu-22.04
7878
install:
7979
- g++-12-multilib
80-
- toolset: gcc-13
81-
cxxstd: "03,11,14,17,20,23"
82-
address_model: 32,64
83-
os: ubuntu-22.04
84-
install:
85-
- g++-13-multilib
86-
cxxflags: -Wno-uninitialized
80+
# Disabled for now. 22.04 dropped support and 24.04 has internal errors
81+
#- toolset: gcc-13
82+
# cxxstd: "03,11,14,17,20,23"
83+
# address_model: 32,64
84+
# os: ubuntu-24.04
85+
# install:
86+
# - g++-13-multilib
87+
# cxxflags: -Wno-uninitialized
8788
- toolset: gcc-12
8889
cxxstd: "03-gnu,11-gnu,14-gnu,17-gnu,20-gnu,23-gnu"
8990
address_model: "32"
@@ -237,9 +238,6 @@ jobs:
237238
- libc++-14-dev
238239
- libc++abi-14-dev
239240

240-
- toolset: clang
241-
cxxstd: "03,11,14,17,2a"
242-
os: macos-11
243241
- toolset: clang
244242
cxxstd: "03,11,14,17,20,2b"
245243
os: macos-12
@@ -517,8 +515,9 @@ jobs:
517515
include:
518516
- os: ubuntu-20.04
519517
- os: ubuntu-22.04
520-
- os: macos-11
521518
- os: macos-12
519+
- os: macos-13
520+
- os: macos-14
522521

523522
runs-on: ${{matrix.os}}
524523

@@ -565,8 +564,9 @@ jobs:
565564
include:
566565
- os: ubuntu-20.04
567566
- os: ubuntu-22.04
568-
- os: macos-11
569567
- os: macos-12
568+
- os: macos-13
569+
- os: macos-14
570570

571571
runs-on: ${{matrix.os}}
572572

@@ -623,8 +623,9 @@ jobs:
623623
include:
624624
- os: ubuntu-20.04
625625
- os: ubuntu-22.04
626-
- os: macos-11
627626
- os: macos-12
627+
- os: macos-13
628+
- os: macos-14
628629

629630
runs-on: ${{matrix.os}}
630631

@@ -680,7 +681,7 @@ jobs:
680681
fail-fast: false
681682
matrix:
682683
include:
683-
#- { sys: MINGW32, compiler: gcc, cxxstd: '03,11,17,20' }
684+
- { sys: MINGW32, compiler: gcc, cxxstd: '03,11,17,20' }
684685
- { sys: MINGW64, compiler: gcc, cxxstd: '03,11,17,20' }
685686

686687
runs-on: windows-latest

README.md

Lines changed: 41 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,69 @@
11
# Decimal
2+
23
| | Master | Develop |
34
|------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------|
45
| Drone | [![Build Status](https://drone.cpp.al/api/badges/cppalliance/decimal/status.svg?ref=refs/heads/master)](https://drone.cpp.al/cppalliance/decimal) | [![Build Status](https://drone.cpp.al/api/badges/cppalliance/decimal/status.svg?ref=refs/heads/develop)](https://drone.cpp.al/cppalliance/decimal) |
5-
| Github Actions | [![CI](https://github.com/cppalliance/decimal/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/cppalliance/decimal/actions/workflows/ci.yml) | [![CI](https://github.com/cppalliance/decimal/actions/workflows/ci.yml/badge.svg?branch=develop)](https://github.com/cppalliance/decimal/actions/workflows/ci.yml)
6-
| Codecov | [![codecov](https://codecov.io/gh/cppalliance/decimal/branch/master/graph/badge.svg?token=drvY8nnV5S)](https://codecov.io/gh/cppalliance/decimal) | [![codecov](https://codecov.io/gh/cppalliance/decimal/graph/badge.svg?token=drvY8nnV5S)](https://codecov.io/gh/cppalliance/decimal) |
7-
| Fuzzing | [![Fuzzing](https://github.com/cppalliance/decimal/actions/workflows/fuzz.yml/badge.svg?branch=master)](https://github.com/cppalliance/decimal/actions/workflows/fuzz.yml) | [![Fuzzing](https://github.com/cppalliance/decimal/actions/workflows/fuzz.yml/badge.svg?branch=develop)](https://github.com/cppalliance/decimal/actions/workflows/fuzz.yml) |
6+
| Github Actions | [![CI](https://github.com/cppalliance/decimal/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/cppalliance/decimal/actions/workflows/ci.yml) | [![CI](https://github.com/cppalliance/decimal/actions/workflows/ci.yml/badge.svg?branch=develop)](https://github.com/cppalliance/decimal/actions/workflows/ci.yml)
7+
| Codecov | [![codecov](https://codecov.io/gh/cppalliance/decimal/branch/master/graph/badge.svg?token=drvY8nnV5S)](https://codecov.io/gh/cppalliance/decimal) | [![codecov](https://codecov.io/gh/cppalliance/decimal/graph/badge.svg?token=drvY8nnV5S)](https://codecov.io/gh/cppalliance/decimal) |
8+
| Fuzzing | [![Fuzzing](https://github.com/cppalliance/decimal/actions/workflows/fuzz.yml/badge.svg?branch=master)](https://github.com/cppalliance/decimal/actions/workflows/fuzz.yml) | [![Fuzzing](https://github.com/cppalliance/decimal/actions/workflows/fuzz.yml/badge.svg?branch=develop)](https://github.com/cppalliance/decimal/actions/workflows/fuzz.yml) |
89

910
---
1011

11-
An implementation of IEEE 754 decimal floating point numbers.
12-
It is header only, and requires C++14
12+
Decimal is an implementation of IEEE-754:2008 decimal floating point numbers.
13+
See also [1].
14+
15+
The library is is header-only, and requires C++14.
16+
It is compatible through C++14, 17, 20, 23 and beyond.
1317

1418
# Notice
1519

16-
This library is not an official boost library, and is under active development.
20+
Decimal is under active development and is not an official boost library.
1721

1822
# How To Use The Library
1923

20-
This library is header only, and contains no dependencies.
24+
This library is header only. It contains no other dependencies.
25+
Simply `#include` it and use it.
2126

2227
## CMake
2328

24-
````
29+
```sh
2530
git clone https://github.com/cppalliance/decimal
2631
cd decimal
2732
mkdir build && cd build
2833
cmake .. OR cmake .. -DCMAKE_INSTALL_PREFIX=/your/custom/path
2934
cmake --install .
30-
````
35+
```
3136

3237
## vcpkg
3338

34-
````
39+
```sh
3540
git clone https://github.com/cppalliance/decimal
3641
cd decimal
3742
vcpkg install decimal --overlay-ports=ports/decimal
38-
````
43+
```
3944

4045
## Conan
4146

42-
````
47+
```sh
4348
git clone https://github.com/cppalliance/decimal
4449
conan create decimal/conan --build missing
45-
````
50+
```
4651

4752
# Supported Platforms
4853

49-
Boost.Decimal is tested on Ubuntu (x86_64, s390x, and aarch64), macOS (x86_64, and Apple Silicon), and Windows (x86_64) with the following compilers:
54+
Boost.Decimal is tested on Ubuntu (x86_64, s390x, and aarch64),
55+
macOS (x86_64, and Apple Silicon), and Windows (x86_64)
56+
with the following compilers:
5057

5158
* GCC 7 and later
5259
* Clang 6 and later
5360
* Visual Studio 2017 and later
5461

5562
# Synopsis
5663

57-
Decimal provides 3 types:
64+
Decimal provides 3 types:
5865

59-
````
66+
```cpp
6067
namespace boost {
6168
namespace decimal {
6269

@@ -66,21 +73,24 @@ class decimal128;
6673

6774
} //namespace decimal
6875
} //namespace boost
69-
````
76+
```
77+
78+
These types operate like built-in floating point types.
79+
They have their own implementations of the Standard-Library functions
80+
(e.g. like those found in `<cmath>`, `<charconv>`, `<cstdlib>`, etc.).
7081
71-
These types operate like built-in floating point types, and have their own implementations of the STL functions (e.g. cmath, charconv, cstdlib, etc.).
7282
The entire library can be conveniently included with `#include <boost/decimal.hpp>`
7383
74-
Using the types is simple:
84+
Using the decimal types is simple.
7585
76-
````
86+
```cpp
7787
#include <boost/decimal.hpp>
7888
#include <iostream>
7989
8090
int main()
8191
{
8292
using boost::decimal::decimal32;
83-
93+
8494
constexpr decimal32 a {2, -1}; // Constructs the number 0.2
8595
constexpr decimal32 b {1, -1}; // Constructs the number 0.1
8696
auto sum {a + b};
@@ -95,11 +105,12 @@ int main()
95105
96106
return 0;
97107
}
98-
````
108+
```
99109

100-
Same with using STL functions:
110+
This intuitive straightforwardness is the same when using Standard-Library
111+
functions (such as STL functions, `<cmath>`-like functions and the like).
101112

102-
````
113+
```cpp
103114
#include <boost/decimal.hpp>
104115
#include <cassert>
105116
#include <cstring>
@@ -123,8 +134,13 @@ int main()
123134

124135
return 0;
125136
}
126-
````
137+
```
127138

128139
# Full Documentation
129140

130141
The complete documentation can be found at: https://cppalliance.org/decimal/decimal.html
142+
143+
## References
144+
145+
[1] IEEE Computer Society. _IEEE_ _Standard_ _for_ _Floating-Point_ _Arithmetic_,
146+
Std. IEEE:754-2008, August 29, 2008 (doi:10.1109/IEEESTD.2008.4610935).

doc/decimal.adoc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ include::decimal/generic_decimal.adoc[]
2020
include::decimal/decimal32.adoc[]
2121
include::decimal/decimal64.adoc[]
2222
include::decimal/decimal128.adoc[]
23+
include::decimal/literals.adoc[]
2324
include::decimal/numbers.adoc[]
2425
include::decimal/cmath.adoc[]
2526
include::decimal/cstdlib.adoc[]
@@ -33,8 +34,8 @@ include::decimal/config.adoc[]
3334
include::decimal/type_traits.adoc[]
3435
include::decimal/examples.adoc[]
3536
include::decimal/benchmarks.adoc[]
36-
//include::decimal/reference.adoc[]
3737
include::decimal/design.adoc[]
38+
include::decimal/reference.adoc[]
3839
include::decimal/copyright.adoc[]
3940

4041
:leveloffset: -1

doc/decimal/charconv.adoc

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ https://www.boost.org/LICENSE_1_0.txt
1212

1313
The following functions analogous to those from https://en.cppreference.com/w/cpp/header/charconv[<charconv>] are provided:
1414

15+
IMPORTANT: `std::from_chars` has an open issue with LWG here: https://cplusplus.github.io/LWG/lwg-active.html#3081.
16+
The standard for <charconv> does not distinguish between underflow and overflow like strtod does.
17+
`boost::decimal::from_chars` modifies `value` in order to communicate this to the user in a divergence from the standard.
18+
This behavior is the same as that of https://www.boost.org/doc/libs/master/libs/charconv/doc/html/charconv.html#from_chars_usage_notes_for_from_chars_for_floating_point_types[`boost::charconv::from_chars_erange`].
19+
1520
[source, c++]
1621
----
1722
namespace boost {
@@ -67,3 +72,44 @@ NOTE: `BOOST_DECIMAL_CONSTEXPR` is defined if:
6772
- `\\__GNUC__` >= 9
6873
- Compiler has: `__builtin_is_constant_evaluated()`
6974
- C++20 support with: `std::is_constant_evaluated()`
75+
76+
The library offers an additional feature for sizing buffers without specified precision and in general format
77+
[source, c++]
78+
----
79+
namespace boost {
80+
namespace decimal {
81+
82+
template <typename T>
83+
struct limits
84+
{
85+
static constexpr int max_chars;
86+
}
87+
88+
} //namespace decimal
89+
} //namespace boost
90+
----
91+
92+
The member can then be used to size buffers such as:
93+
94+
[source, c++]
95+
----
96+
#include <boost/decimal.hpp>
97+
#include <iostream>
98+
99+
int main()
100+
{
101+
using namespace boost::decimal;
102+
103+
decimal32 val {5, -1};
104+
105+
char buffer[limits<T>::max_chars];
106+
107+
auto r_to = to_chars(buffer, buffer + sizeof(buffer), val);
108+
*r_to.ptr = '\0';
109+
110+
std::cout << buffer << std::endl;
111+
112+
return 0;
113+
}
114+
115+
----

doc/decimal/decimal128.adoc

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -83,14 +83,6 @@ explicit constexpr operator std::bfloat16_t() const noexcept;
8383
explicit constexpr operator decimal32() const noexcept;
8484
explicit constexpr operator decimal64() const noexcept;
8585
86-
// Literals
87-
constexpr auto operator "" _DL(const char* str) -> decimal128
88-
constexpr auto operator "" _dl(const char* str) -> decimal128
89-
constexpr auto operator "" _DL(unsigned long long v) -> decimal128
90-
constexpr auto operator "" _dl(unsigned long long v) -> decimal128
91-
BOOST_DECIMAL_CXX20_CONSTEXPR auto operator "" _DL(long double v) -> decimal128
92-
BOOST_DECIMAL_CXX20_CONSTEXPR auto operator "" _dl(long double v) -> decimal128
93-
9486
} //namespace decimal
9587
} //namespace boost
9688

0 commit comments

Comments
 (0)