1#ifndef FASTFLOAT_DIGIT_COMPARISON_H
2#define FASTFLOAT_DIGIT_COMPARISON_H
17 1UL, 10UL, 100UL, 1000UL, 10000UL, 100000UL, 1000000UL, 10000000UL, 100000000UL,
18 1000000000UL, 10000000000UL, 100000000000UL, 1000000000000UL, 10000000000000UL,
19 100000000000000UL, 1000000000000000UL, 10000000000000000UL, 100000000000000000UL,
20 1000000000000000000UL, 10000000000000000000UL};
27 uint64_t mantissa = num.mantissa;
28 int32_t exponent = int32_t(num.exponent);
29 while (mantissa >= 10000) {
33 while (mantissa >= 100) {
37 while (mantissa >= 10) {
55 ::memcpy(&
bits, &value,
sizeof(T));
56 if ((
bits & exponent_mask) == 0) {
83template <
typename T,
typename callback>
86 if (-am.power2 >= mantissa_shift) {
88 int32_t shift = -am.power2 + 1;
89 cb(am, std::min<int32_t>(shift, 64));
96 cb(am, mantissa_shift);
112template <
typename callback>
120 mask = (uint64_t(1) << shift) - 1;
125 halfway = uint64_t(1) << (shift - 1);
127 uint64_t truncated_bits = am.mantissa & mask;
128 uint64_t is_above = truncated_bits > halfway;
129 uint64_t is_halfway = truncated_bits == halfway;
135 am.mantissa >>= shift;
139 bool is_odd = (am.mantissa & 1) == 1;
140 am.mantissa += uint64_t(cb(is_odd, is_halfway, is_above));
147 am.mantissa >>= shift;
154 while (std::distance(first,
last) >= 8) {
155 ::memcpy(&val, first,
sizeof(uint64_t));
156 if (val != 0x3030303030303030) {
161 while (first !=
last) {
174 while (std::distance(first,
last) >= 8) {
175 ::memcpy(&val, first,
sizeof(uint64_t));
176 if (val != 0x3030303030303030) {
181 while (first !=
last) {
204 value = value * 10 +
limb(*p -
'0');
231#ifdef FASTFLOAT_64BIT_LIMB
238 const char* p = num.integer.ptr;
239 const char* pend = p + num.integer.len();
243 while ((std::distance(p, pend) >= 8) && (step - counter >= 8) && (max_digits - digits >= 8)) {
246 while (counter < step && p != pend && digits < max_digits) {
249 if (digits == max_digits) {
253 if (num.fraction.ptr !=
nullptr) {
268 if (num.fraction.ptr !=
nullptr) {
269 p = num.fraction.ptr;
270 pend = p + num.fraction.len();
276 while ((std::distance(p, pend) >= 8) && (step - counter >= 8) && (max_digits - digits >= 8)) {
279 while (counter < step && p != pend && digits < max_digits) {
282 if (digits == max_digits) {
308 answer.
mantissa = bigmant.hi64(truncated);
310 answer.
power2 = bigmant.bit_length() - 64 + bias;
314 return is_above || (is_halfway && truncated) || (is_odd && is_halfway);
328 bigint& real_digits = bigmant;
329 int32_t real_exp = exponent;
339 int32_t theor_exp = theor.
power2;
342 int32_t pow2_exp = theor_exp - real_exp;
343 uint32_t pow5_exp = uint32_t(-real_exp);
349 }
else if (pow2_exp < 0) {
362 }
else if (
ord < 0) {
397 int32_t exponent = sci_exp + 1 - int32_t(digits);
399 return positive_digit_comp<T>(bigmant, exponent);
401 return negative_digit_comp<T>(bigmant, am, exponent);
#define FASTFLOAT_ASSERT(x)
#define fastfloat_really_inline
CONSTDATA date::last_spec last
constexpr fastfloat_really_inline int32_t power(int32_t q) noexcept
fastfloat_really_inline adjusted_mantissa to_extended_halfway(T value) noexcept
fastfloat_really_inline void round_down(adjusted_mantissa &am, int32_t shift) noexcept
fastfloat_really_inline void parse_one_digit(const char *&p, limb &value, size_t &counter, size_t &count) noexcept
fastfloat_really_inline void to_float(bool negative, adjusted_mantissa am, T &value)
fastfloat_really_inline uint32_t parse_eight_digits_unrolled(uint64_t val)
fastfloat_really_inline int32_t scientific_exponent(parsed_number_string &num) noexcept
static constexpr int32_t invalid_am_bias
fastfloat_really_inline void parse_eight_digits(const char *&p, limb &value, size_t &counter, size_t &count) noexcept
adjusted_mantissa digit_comp(parsed_number_string &num, adjusted_mantissa am) noexcept
fastfloat_really_inline void skip_zeros(const char *&first, const char *last) noexcept
fastfloat_really_inline void round_nearest_tie_even(adjusted_mantissa &am, int32_t shift, callback cb) noexcept
fastfloat_really_inline bool is_truncated(const char *first, const char *last) noexcept
adjusted_mantissa negative_digit_comp(bigint &bigmant, adjusted_mantissa am, int32_t exponent) noexcept
fastfloat_really_inline adjusted_mantissa to_extended(T value) noexcept
void parse_mantissa(bigint &result, parsed_number_string &num, size_t max_digits, size_t &digits) noexcept
fastfloat_really_inline void round(adjusted_mantissa &am, callback cb) noexcept
fastfloat_really_inline void round_up_bigint(bigint &big, size_t &count) noexcept
static constexpr uint64_t powers_of_ten_uint64[]
fastfloat_really_inline void add_native(bigint &big, limb power, limb value) noexcept
adjusted_mantissa positive_digit_comp(bigint &bigmant, int32_t exponent) noexcept
CONSTDATA solar_hijri::month ord
bool pow2(uint32_t exp) noexcept
bool pow5(uint32_t exp) noexcept
int compare(const bigint &other) const noexcept