Skip to content

Commit 28e7560

Browse files
authored
Merge pull request #253 from fastfloat/update_ci_to_ubuntu24
update CI to ubuntu 24 + safe a shift value to a variable (for elegance)
2 parents 9468d50 + d65638b commit 28e7560

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
1-
name: Ubuntu 22.04 CI (GCC 13)
1+
name: Ubuntu 24.04 CI (GCC 13)
22

33
on: [push, pull_request]
44

55
jobs:
66
ubuntu-build:
7-
runs-on: ubuntu-22.04
7+
runs-on: ubuntu-24.04
88
steps:
99
- uses: actions/checkout@v3
1010
- name: Use cmake
1111
run: |
1212
mkdir build &&
1313
cd build &&
14-
CXX=g++-13 CXXFLAGS=-Werror cmake -DFASTFLOAT_TEST=ON .. &&
14+
CXXFLAGS=-Werror cmake -DFASTFLOAT_TEST=ON .. &&
1515
cmake --build . &&
1616
ctest --output-on-failure
1717
- name: Use cmake CXX23
1818
run: |
1919
mkdir build20 &&
2020
cd build20 &&
21-
CXX=g++-13 CXXFLAGS=-Werror cmake -DFASTFLOAT_CONSTEXPR_TESTS=ON -DFASTFLOAT_FIXEDWIDTH_TESTS=ON -DFASTFLOAT_CXX_STANDARD=23 -DFASTFLOAT_TEST=ON .. &&
21+
CXXFLAGS=-Werror cmake -DFASTFLOAT_CONSTEXPR_TESTS=ON -DFASTFLOAT_FIXEDWIDTH_TESTS=ON -DFASTFLOAT_CXX_STANDARD=23 -DFASTFLOAT_TEST=ON .. &&
2222
cmake --build . &&
2323
ctest --output-on-failure

include/fast_float/decimal_to_binary.h

+3-2
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,9 @@ adjusted_mantissa compute_float(int64_t q, uint64_t w) noexcept {
127127
// but in practice, we can win big with the compute_product_approximation if its additional branch
128128
// is easily predicted. Which is best is data specific.
129129
int upperbit = int(product.high >> 63);
130+
int shift = upperbit + 64 - binary::mantissa_explicit_bits() - 3;
130131

131-
answer.mantissa = product.high >> (upperbit + 64 - binary::mantissa_explicit_bits() - 3);
132+
answer.mantissa = product.high >> shift;
132133

133134
answer.power2 = int32_t(detail::power(int32_t(q)) + upperbit - lz - binary::minimum_exponent());
134135
if (answer.power2 <= 0) { // we have a subnormal?
@@ -164,7 +165,7 @@ adjusted_mantissa compute_float(int64_t q, uint64_t w) noexcept {
164165
// To be in-between two floats we need that in doing
165166
// answer.mantissa = product.high >> (upperbit + 64 - binary::mantissa_explicit_bits() - 3);
166167
// ... we dropped out only zeroes. But if this happened, then we can go back!!!
167-
if((answer.mantissa << (upperbit + 64 - binary::mantissa_explicit_bits() - 3)) == product.high) {
168+
if((answer.mantissa << shift) == product.high) {
168169
answer.mantissa &= ~uint64_t(1); // flip it so that we do not round up
169170
}
170171
}

0 commit comments

Comments
 (0)