Skip to content

Commit

Permalink
Merge pull request #585 from cppalliance/develop
Browse files Browse the repository at this point in the history
Merge to Master for v1.2.0
  • Loading branch information
mborland authored May 22, 2024
2 parents b7b1ffa + d901dd4 commit 67793ad
Show file tree
Hide file tree
Showing 79 changed files with 7,056 additions and 1,474 deletions.
50 changes: 36 additions & 14 deletions .drone.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -98,17 +98,17 @@ local windows_pipeline(name, image, environment, arch = "amd64") =
[

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

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

linux_pipeline(
Expand Down Expand Up @@ -173,19 +173,33 @@ local windows_pipeline(name, image, environment, arch = "amd64") =
),

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

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

linux_pipeline(
"Linux 24.04 GCC 14 32/64",
"cppalliance/droneubuntu2404:1",
{ TOOLSET: 'gcc', COMPILER: 'g++-14', CXXSTD: '03,11,14,17,20,23', ADDRMD: '32,64', CXXFLAGS: "-fexcess-precision=fast" },
"g++-14-multilib",
),

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

linux_pipeline(
"Linux 18.04 GCC 7* 32 03",
"cppalliance/droneubuntu1804:1",
Expand Down Expand Up @@ -329,13 +343,21 @@ local windows_pipeline(name, image, environment, arch = "amd64") =
),

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

linux_pipeline(
"Linux 24.04 Clang 18",
"cppalliance/droneubuntu2404:1",
{ TOOLSET: 'clang', COMPILER: 'clang++-18', CXXSTD: '03,11,14,17,20,2b' },
"clang-18",
["deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-18 main"],
),

macos_pipeline(
"MacOS 10.15 Xcode 12.2 UBSAN",
{ TOOLSET: 'clang', COMPILER: 'clang++', CXXSTD: '03,11,14,17,2a' } + ubsan,
Expand Down
29 changes: 15 additions & 14 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,14 @@ jobs:
os: ubuntu-22.04
install:
- g++-12-multilib
- toolset: gcc-13
cxxstd: "03,11,14,17,20,23"
address_model: 32,64
os: ubuntu-22.04
install:
- g++-13-multilib
cxxflags: -Wno-uninitialized
# Disabled for now. 22.04 dropped support and 24.04 has internal errors
#- toolset: gcc-13
# cxxstd: "03,11,14,17,20,23"
# address_model: 32,64
# os: ubuntu-24.04
# install:
# - g++-13-multilib
# cxxflags: -Wno-uninitialized
- toolset: gcc-12
cxxstd: "03-gnu,11-gnu,14-gnu,17-gnu,20-gnu,23-gnu"
address_model: "32"
Expand Down Expand Up @@ -237,9 +238,6 @@ jobs:
- libc++-14-dev
- libc++abi-14-dev

- toolset: clang
cxxstd: "03,11,14,17,2a"
os: macos-11
- toolset: clang
cxxstd: "03,11,14,17,20,2b"
os: macos-12
Expand Down Expand Up @@ -517,8 +515,9 @@ jobs:
include:
- os: ubuntu-20.04
- os: ubuntu-22.04
- os: macos-11
- os: macos-12
- os: macos-13
- os: macos-14

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

Expand Down Expand Up @@ -565,8 +564,9 @@ jobs:
include:
- os: ubuntu-20.04
- os: ubuntu-22.04
- os: macos-11
- os: macos-12
- os: macos-13
- os: macos-14

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

Expand Down Expand Up @@ -623,8 +623,9 @@ jobs:
include:
- os: ubuntu-20.04
- os: ubuntu-22.04
- os: macos-11
- os: macos-12
- os: macos-13
- os: macos-14

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

Expand Down Expand Up @@ -680,7 +681,7 @@ jobs:
fail-fast: false
matrix:
include:
#- { sys: MINGW32, compiler: gcc, cxxstd: '03,11,17,20' }
- { sys: MINGW32, compiler: gcc, cxxstd: '03,11,17,20' }
- { sys: MINGW64, compiler: gcc, cxxstd: '03,11,17,20' }

runs-on: windows-latest
Expand Down
66 changes: 41 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,62 +1,69 @@
# Decimal

| | Master | Develop |
|------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------|
| 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) |
| 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)
| 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) |
| 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) |
| 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)
| 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) |
| 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) |

---

An implementation of IEEE 754 decimal floating point numbers.
It is header only, and requires C++14
Decimal is an implementation of IEEE-754:2008 decimal floating point numbers.
See also [1].

The library is is header-only, and requires C++14.
It is compatible through C++14, 17, 20, 23 and beyond.

# Notice

This library is not an official boost library, and is under active development.
Decimal is under active development and is not an official boost library.

# How To Use The Library

This library is header only, and contains no dependencies.
This library is header only. It contains no other dependencies.
Simply `#include` it and use it.

## CMake

````
```sh
git clone https://github.com/cppalliance/decimal
cd decimal
mkdir build && cd build
cmake .. OR cmake .. -DCMAKE_INSTALL_PREFIX=/your/custom/path
cmake --install .
````
```

## vcpkg

````
```sh
git clone https://github.com/cppalliance/decimal
cd decimal
vcpkg install decimal --overlay-ports=ports/decimal
````
```

## Conan

````
```sh
git clone https://github.com/cppalliance/decimal
conan create decimal/conan --build missing
````
```

# Supported Platforms

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:
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:

* GCC 7 and later
* Clang 6 and later
* Visual Studio 2017 and later

# Synopsis

Decimal provides 3 types:
Decimal provides 3 types:

````
```cpp
namespace boost {
namespace decimal {

Expand All @@ -66,21 +73,24 @@ class decimal128;

} //namespace decimal
} //namespace boost
````
```
These types operate like built-in floating point types.
They have their own implementations of the Standard-Library functions
(e.g. like those found in `<cmath>`, `<charconv>`, `<cstdlib>`, etc.).
These types operate like built-in floating point types, and have their own implementations of the STL functions (e.g. cmath, charconv, cstdlib, etc.).
The entire library can be conveniently included with `#include <boost/decimal.hpp>`
Using the types is simple:
Using the decimal types is simple.
````
```cpp
#include <boost/decimal.hpp>
#include <iostream>
int main()
{
using boost::decimal::decimal32;
constexpr decimal32 a {2, -1}; // Constructs the number 0.2
constexpr decimal32 b {1, -1}; // Constructs the number 0.1
auto sum {a + b};
Expand All @@ -95,11 +105,12 @@ int main()
return 0;
}
````
```

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

````
```cpp
#include <boost/decimal.hpp>
#include <cassert>
#include <cstring>
Expand All @@ -123,8 +134,13 @@ int main()

return 0;
}
````
```

# Full Documentation

The complete documentation can be found at: https://cppalliance.org/decimal/decimal.html

## References

[1] IEEE Computer Society. _IEEE_ _Standard_ _for_ _Floating-Point_ _Arithmetic_,
Std. IEEE:754-2008, August 29, 2008 (doi:10.1109/IEEESTD.2008.4610935).
3 changes: 2 additions & 1 deletion doc/decimal.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ include::decimal/generic_decimal.adoc[]
include::decimal/decimal32.adoc[]
include::decimal/decimal64.adoc[]
include::decimal/decimal128.adoc[]
include::decimal/literals.adoc[]
include::decimal/numbers.adoc[]
include::decimal/cmath.adoc[]
include::decimal/cstdlib.adoc[]
Expand All @@ -33,8 +34,8 @@ include::decimal/config.adoc[]
include::decimal/type_traits.adoc[]
include::decimal/examples.adoc[]
include::decimal/benchmarks.adoc[]
//include::decimal/reference.adoc[]
include::decimal/design.adoc[]
include::decimal/reference.adoc[]
include::decimal/copyright.adoc[]

:leveloffset: -1
46 changes: 46 additions & 0 deletions doc/decimal/charconv.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ https://www.boost.org/LICENSE_1_0.txt

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

IMPORTANT: `std::from_chars` has an open issue with LWG here: https://cplusplus.github.io/LWG/lwg-active.html#3081.
The standard for <charconv> does not distinguish between underflow and overflow like strtod does.
`boost::decimal::from_chars` modifies `value` in order to communicate this to the user in a divergence from the standard.
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`].

[source, c++]
----
namespace boost {
Expand Down Expand Up @@ -67,3 +72,44 @@ NOTE: `BOOST_DECIMAL_CONSTEXPR` is defined if:
- `\\__GNUC__` >= 9
- Compiler has: `__builtin_is_constant_evaluated()`
- C++20 support with: `std::is_constant_evaluated()`

The library offers an additional feature for sizing buffers without specified precision and in general format
[source, c++]
----
namespace boost {
namespace decimal {
template <typename T>
struct limits
{
static constexpr int max_chars;
}
} //namespace decimal
} //namespace boost
----

The member can then be used to size buffers such as:

[source, c++]
----
#include <boost/decimal.hpp>
#include <iostream>
int main()
{
using namespace boost::decimal;
decimal32 val {5, -1};
char buffer[limits<T>::max_chars];
auto r_to = to_chars(buffer, buffer + sizeof(buffer), val);
*r_to.ptr = '\0';
std::cout << buffer << std::endl;
return 0;
}
----
8 changes: 0 additions & 8 deletions doc/decimal/decimal128.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,6 @@ explicit constexpr operator std::bfloat16_t() const noexcept;
explicit constexpr operator decimal32() const noexcept;
explicit constexpr operator decimal64() const noexcept;
// Literals
constexpr auto operator "" _DL(const char* str) -> decimal128
constexpr auto operator "" _dl(const char* str) -> decimal128
constexpr auto operator "" _DL(unsigned long long v) -> decimal128
constexpr auto operator "" _dl(unsigned long long v) -> decimal128
BOOST_DECIMAL_CXX20_CONSTEXPR auto operator "" _DL(long double v) -> decimal128
BOOST_DECIMAL_CXX20_CONSTEXPR auto operator "" _dl(long double v) -> decimal128
} //namespace decimal
} //namespace boost
Expand Down
Loading

0 comments on commit 67793ad

Please sign in to comment.