Skip to content

Commit

Permalink
Merge branch 'main' into issue111
Browse files Browse the repository at this point in the history
  • Loading branch information
ckormanyos committed Feb 4, 2024
2 parents 17fef2d + e974148 commit fe6afb1
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 31 deletions.
32 changes: 16 additions & 16 deletions .github/workflows/soft_double.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
compiler: [ g++-11, clang++ ]
standard: [ c++14, c++17, c++20 ]
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: '0'
- name: update-tools
Expand All @@ -50,7 +50,7 @@ jobs:
runs-on: ubuntu-latest
container: ${{matrix.container}}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: create build directory
run: mkdir $GITHUB_WORKSPACE/build
- name: build
Expand All @@ -70,7 +70,7 @@ jobs:
cmake-windows:
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: create build directory
run: mkdir ${{runner.workspace}}/build
- name: build
Expand All @@ -93,7 +93,7 @@ jobs:
standard: [ c++20 ]
compiler: [ g++, clang++ ]
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: '0'
- name: update-tools
Expand Down Expand Up @@ -121,7 +121,7 @@ jobs:
compiler: [ g++-12, clang++-14 ]
standard: [ c++14, c++17, c++20 ]
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: '0'
- name: update-tools
Expand All @@ -144,7 +144,7 @@ jobs:
compiler: [ g++ ]
standard: [ c++14, c++17, c++2a ]
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: '0'
- name: mingw-winhost-x64
Expand All @@ -165,7 +165,7 @@ jobs:
compiler: [ g++-11, clang++ ]
standard: [ c++14, c++17, c++20 ]
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: '0'
- name: update-tools
Expand All @@ -188,7 +188,7 @@ jobs:
compiler: [ g++-11, clang++ ]
standard: [ c++14, c++17, c++20 ]
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: '0'
- name: update-tools
Expand All @@ -211,7 +211,7 @@ jobs:
compiler: [ g++, clang++ ]
standard: [ c++14, c++17, c++20 ]
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: '0'
- name: apple-gcc-clang-native
Expand All @@ -224,7 +224,7 @@ jobs:
msvc-release-x64:
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: ilammy/msvc-dev-cmd@v1
with:
toolset: 14.2
Expand All @@ -238,10 +238,10 @@ jobs:
msvc-release-x64-vs2022:
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: '0'
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: ilammy/msvc-dev-cmd@v1
with:
toolset: 14.3
Expand All @@ -262,7 +262,7 @@ jobs:
matrix:
standard: [ c++14 ]
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: '0'
- name: update-tools
Expand All @@ -286,7 +286,7 @@ jobs:
ls -la bin/example010_hypergeometric_2f1.elf bin/example010_hypergeometric_2f1.map bin/example010_hypergeometric_2f1.hex
working-directory: ./
gcc-arm-none-eabi:
runs-on: ubuntu-22.04
runs-on: ubuntu-latest
defaults:
run:
shell: bash
Expand All @@ -295,7 +295,7 @@ jobs:
matrix:
standard: [ c++14, c++17, c++2a ]
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: '0'
- name: update-tools
Expand Down Expand Up @@ -337,7 +337,7 @@ jobs:
compiler: [ g++, clang++ ]
suite: [ cyl_bessel_j ]
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: '0'
- name: clone-submods-bootstrap-headers-boost-develop
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/soft_double_codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
standard: [ c++14 ]
compiler: [ g++ ]
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: '0'
- name: update-tools
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/soft_double_sonar.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
SONAR_SERVER_URL: "https://sonarcloud.io"
BUILD_WRAPPER_OUT_DIR: build_wrapper_output_directory # Directory where build-wrapper output will be placed
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up JDK 17
Expand Down
19 changes: 9 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ soft_double
<img src="https://img.shields.io/github/commit-activity/y/ckormanyos/soft_double" alt="GitHub commit activity"></a>
<a href="https://github.com/ckormanyos/soft_double">
<img src="https://img.shields.io/github/languages/code-size/ckormanyos/soft_double" alt="GitHub code size in bytes"></a>
<a href="https://godbolt.org/z/vj7a1bY6x" alt="godbolt">
<a href="https://godbolt.org/z/oqh333Y33" alt="godbolt">
<img src="https://img.shields.io/badge/try%20it%20on-godbolt-green" /></a>
</p>

Expand Down Expand Up @@ -165,7 +165,7 @@ how to use soft_double.
- ![`example011_trig_trapezoid_integral.cpp`](./examples/example011_trig_trapezoid_integral.cpp) uses trapezoid integration with an integral representation involving locally-written trigonometric sine and cosine functions to compute several cylindrical Bessel function values.
- ![`example012_exercise_constexpr.cpp`](./examples/example012_exercise_constexpr.cpp) verifies that C++20 `constexpr`-ness works properly for both rudimentary assignment-operation as well as an elementary square root function.

## C++14, 17, 20 `constexpr` support
## C++20 `constexpr` support

When using C++20, `soft_double` supports compile-time
`constexpr` construction and evaluation of results
Expand Down Expand Up @@ -212,14 +212,13 @@ int main()
}
```

`constexpr`-_ness_ of `soft_double` has been checked on GCC 10 and up, clang 10 and up
(with `-std=c++20`) and VC 14.2 (with `/std:c++latest`),
also for various embedded compilers such as `avr-gcc` 10 and up,
`arm-non-eabi-gcc` 10 and up, and more. In addition,
less modern compiler versions in addition to some other compilers
having standards such as C++14, 17, 2a have also been checked
for `constexpr` usage of `soft_double`. If you have an older
compiler, you might have to check the compiler's
`constexpr`-ness of `soft_double` has been checked on GCC, clang
(with `-std=c++20` and beyond) and VC 14.2 and higher (with `/std:c++latest`),
also for various embedded compilers such as `avr-gcc` 11 and up,
`arm-non-eabi-gcc` 11 and up, and more.
In addition, less modern compiler versions have been sporadically
(not exhaustively) checked for `constexpr` usage of `soft_double`.
If you have an older compiler, you might have to check the compiler's
ability to obtain the entire benefit of `constexpr` with `soft_double`.

In [issue 110](https://github.com/ckormanyos/soft_double/issues/110),
Expand Down
2 changes: 1 addition & 1 deletion examples/example012_exercise_constexpr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ auto math::softfloat::example012_exercise_constexpr() -> bool
#include <iomanip>
#include <iostream>

int main()
auto main() -> int
{
const bool result_is_ok = math::softfloat::example012_exercise_constexpr();

Expand Down
2 changes: 1 addition & 1 deletion math/softfloat/soft_double.h
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
};
}

#if (defined(SOFT_DOUBLE_CONSTEXPR_BUILTIN_FLOATS) && (SOFT_DOUBLE_CONSTEXPR_BUILTIN_FLOATS == 0))
#if (defined(SOFT_DOUBLE_CONSTEXPR_BUILTIN_FLOATS) && (SOFT_DOUBLE_CONSTEXPR_BUILTIN_FLOATS == 0))

template<typename BuiltInFloatType,
typename ExactUnsignedIntegralType = typename uint_type_helper<std::numeric_limits<BuiltInFloatType>::digits>::exact_unsigned_type>
Expand Down
14 changes: 13 additions & 1 deletion test/test_soft_double_spot_values.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////
// Copyright Christopher Kormanyos 2022 - 2023. //
// Copyright Christopher Kormanyos 2022 - 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 @@ -86,10 +86,22 @@ namespace local
constexpr auto ctrl_d2 = ::math::softfloat::float64_t { static_cast<int>(INT8_C(1)) } / static_cast<int>(INT8_C(2));
constexpr auto ctrl_d3 = ::math::softfloat::float64_t { static_cast<int>(INT8_C(5)) } / static_cast<int>(INT8_C(8));

#if ((defined SOFT_DOUBLE_CONSTEXPR_BUILTIN_FLOATS) && (SOFT_DOUBLE_CONSTEXPR_BUILTIN_FLOATS == 1))
constexpr auto sd0 = ::math::softfloat::float64_t { f0 };
constexpr auto sd1 = ::math::softfloat::float64_t { f1 };
constexpr auto sd2 = ::math::softfloat::float64_t { f2 };
constexpr auto sd3 = ::math::softfloat::float64_t { f3 };

static_assert(sd0 == ctrl_d0, "Error: Initialization from constexpr-float does not properly work");
static_assert(sd1 == ctrl_d1, "Error: Initialization from constexpr-float does not properly work");
static_assert(sd2 == ctrl_d2, "Error: Initialization from constexpr-float does not properly work");
static_assert(sd3 == ctrl_d3, "Error: Initialization from constexpr-float does not properly work");
#else
const auto sd0 = ::math::softfloat::float64_t { f0 };
const auto sd1 = ::math::softfloat::float64_t { f1 };
const auto sd2 = ::math::softfloat::float64_t { f2 };
const auto sd3 = ::math::softfloat::float64_t { f3 };
#endif

auto result_construct_from_float_is_ok =
(
Expand Down

0 comments on commit fe6afb1

Please sign in to comment.