Merge pull request #253 from fastfloat/update_ci_to_ubuntu24

update CI to ubuntu 24 + safe a shift value to a variable (for elegance)
This commit is contained in:
Daniel Lemire 2024-07-22 09:41:38 -04:00 committed by GitHub
commit 28e7560c23
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 7 additions and 6 deletions

View File

@ -1,23 +1,23 @@
name: Ubuntu 22.04 CI (GCC 13) name: Ubuntu 24.04 CI (GCC 13)
on: [push, pull_request] on: [push, pull_request]
jobs: jobs:
ubuntu-build: ubuntu-build:
runs-on: ubuntu-22.04 runs-on: ubuntu-24.04
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- name: Use cmake - name: Use cmake
run: | run: |
mkdir build && mkdir build &&
cd build && cd build &&
CXX=g++-13 CXXFLAGS=-Werror cmake -DFASTFLOAT_TEST=ON .. && CXXFLAGS=-Werror cmake -DFASTFLOAT_TEST=ON .. &&
cmake --build . && cmake --build . &&
ctest --output-on-failure ctest --output-on-failure
- name: Use cmake CXX23 - name: Use cmake CXX23
run: | run: |
mkdir build20 && mkdir build20 &&
cd build20 && cd build20 &&
CXX=g++-13 CXXFLAGS=-Werror cmake -DFASTFLOAT_CONSTEXPR_TESTS=ON -DFASTFLOAT_FIXEDWIDTH_TESTS=ON -DFASTFLOAT_CXX_STANDARD=23 -DFASTFLOAT_TEST=ON .. && CXXFLAGS=-Werror cmake -DFASTFLOAT_CONSTEXPR_TESTS=ON -DFASTFLOAT_FIXEDWIDTH_TESTS=ON -DFASTFLOAT_CXX_STANDARD=23 -DFASTFLOAT_TEST=ON .. &&
cmake --build . && cmake --build . &&
ctest --output-on-failure ctest --output-on-failure

View File

@ -127,8 +127,9 @@ adjusted_mantissa compute_float(int64_t q, uint64_t w) noexcept {
// but in practice, we can win big with the compute_product_approximation if its additional branch // but in practice, we can win big with the compute_product_approximation if its additional branch
// is easily predicted. Which is best is data specific. // is easily predicted. Which is best is data specific.
int upperbit = int(product.high >> 63); int upperbit = int(product.high >> 63);
int shift = upperbit + 64 - binary::mantissa_explicit_bits() - 3;
answer.mantissa = product.high >> (upperbit + 64 - binary::mantissa_explicit_bits() - 3); answer.mantissa = product.high >> shift;
answer.power2 = int32_t(detail::power(int32_t(q)) + upperbit - lz - binary::minimum_exponent()); answer.power2 = int32_t(detail::power(int32_t(q)) + upperbit - lz - binary::minimum_exponent());
if (answer.power2 <= 0) { // we have a subnormal? if (answer.power2 <= 0) { // we have a subnormal?
@ -164,7 +165,7 @@ adjusted_mantissa compute_float(int64_t q, uint64_t w) noexcept {
// To be in-between two floats we need that in doing // To be in-between two floats we need that in doing
// answer.mantissa = product.high >> (upperbit + 64 - binary::mantissa_explicit_bits() - 3); // answer.mantissa = product.high >> (upperbit + 64 - binary::mantissa_explicit_bits() - 3);
// ... we dropped out only zeroes. But if this happened, then we can go back!!! // ... we dropped out only zeroes. But if this happened, then we can go back!!!
if((answer.mantissa << (upperbit + 64 - binary::mantissa_explicit_bits() - 3)) == product.high) { if((answer.mantissa << shift) == product.high) {
answer.mantissa &= ~uint64_t(1); // flip it so that we do not round up answer.mantissa &= ~uint64_t(1); // flip it so that we do not round up
} }
} }