|
25 | 25 | #include <vector> |
26 | 26 |
|
27 | 27 | #include "absl/base/casts.h" |
28 | | -#include "absl/base/internal/endian.h" |
29 | 28 | #include "absl/log/check.h" |
30 | 29 | #include "absl/types/span.h" |
31 | 30 | #include "ortools/util/bitset.h" |
@@ -230,33 +229,4 @@ int64_t ComputeGcdOfRoundedDoubles(absl::Span<const double> x, |
230 | 229 | return gcd > 0 ? gcd : 1; |
231 | 230 | } |
232 | 231 |
|
233 | | -int fast_ilogb(double value) { |
234 | | - static_assert(CHAR_BIT == 8); |
235 | | - static_assert(sizeof(double) == 8); |
236 | | - // Get little-endian bit-representation of the floating point value. |
237 | | - const uint64_t bit_rep = |
238 | | - absl::little_endian::FromHost64(absl::bit_cast<uint64_t>(value)); |
239 | | - return static_cast<int>((bit_rep >> 52) & 0x7FF) - 1023; |
240 | | -} |
241 | | - |
242 | | -void fast_scalbn_inplace(double& mutable_value, int exponent) { |
243 | | - mutable_value = fast_scalbn(mutable_value, exponent); |
244 | | -} |
245 | | - |
246 | | -double fast_scalbn(double value, int exponent) { |
247 | | - if (value == 0.0) return 0.0; |
248 | | - uint64_t bit_rep = |
249 | | - absl::little_endian::FromHost64(absl::bit_cast<uint64_t>(value)); |
250 | | - // Binary representation is: (sign-bit)(11 exponent bits)(52 mantissa bits) |
251 | | - constexpr uint64_t kExponentMask(0x7FF0000000000000); |
252 | | - // This addition relies on the fact that signed numbers are written in |
253 | | - // two-s complement, and is correct as long as the sum does not |
254 | | - // overflow/underflow the result. |
255 | | - const uint64_t value_exponent = |
256 | | - (bit_rep + (static_cast<uint64_t>(exponent) << 52)) & kExponentMask; |
257 | | - bit_rep &= ~kExponentMask; |
258 | | - bit_rep |= value_exponent; |
259 | | - return absl::bit_cast<double>(absl::little_endian::ToHost64(bit_rep)); |
260 | | -} |
261 | | - |
262 | 232 | } // namespace operations_research |
0 commit comments