|
NumeRe v1.1.4
NumeRe: Framework für Numerische Rechnungen
|
Namespaces | |
| namespace | detail |
Classes | |
| struct | adjusted_mantissa |
| struct | bigint |
| struct | binary_format |
| struct | from_chars_result |
| struct | parse_options |
| struct | parsed_number_string |
| struct | powers_template |
| struct | span |
| struct | stackvec |
| struct | value128 |
Typedefs | |
| typedef span< const char > | byte_span |
| typedef uint32_t | limb |
| typedef span< limb > | limb_span |
| using | powers = powers_template<> |
Enumerations | |
| enum | chars_format { scientific = 1<<0 , fixed = 1<<2 , hex = 1<<3 , general = fixed | scientific } |
Functions | |
| fastfloat_really_inline bool | is_integer (char c) noexcept |
| fastfloat_really_inline uint64_t | byteswap (uint64_t val) |
| fastfloat_really_inline uint64_t | read_u64 (const char *chars) |
| fastfloat_really_inline void | write_u64 (uint8_t *chars, uint64_t val) |
| fastfloat_really_inline uint32_t | parse_eight_digits_unrolled (uint64_t val) |
| fastfloat_really_inline uint32_t | parse_eight_digits_unrolled (const char *chars) noexcept |
| fastfloat_really_inline bool | is_made_of_eight_digits_fast (uint64_t val) noexcept |
| fastfloat_really_inline bool | is_made_of_eight_digits_fast (const char *chars) noexcept |
| fastfloat_really_inline parsed_number_string | parse_number_string (const char *p, const char *pend, parse_options options) noexcept |
| fastfloat_really_inline uint64_t | empty_hi64 (bool &truncated) noexcept |
| fastfloat_really_inline uint64_t | uint64_hi64 (uint64_t r0, bool &truncated) noexcept |
| fastfloat_really_inline uint64_t | uint64_hi64 (uint64_t r0, uint64_t r1, bool &truncated) noexcept |
| fastfloat_really_inline uint64_t | uint32_hi64 (uint32_t r0, bool &truncated) noexcept |
| fastfloat_really_inline uint64_t | uint32_hi64 (uint32_t r0, uint32_t r1, bool &truncated) noexcept |
| fastfloat_really_inline uint64_t | uint32_hi64 (uint32_t r0, uint32_t r1, uint32_t r2, bool &truncated) noexcept |
| fastfloat_really_inline limb | scalar_add (limb x, limb y, bool &overflow) noexcept |
| fastfloat_really_inline limb | scalar_mul (limb x, limb y, limb &carry) noexcept |
| template<uint16_t size> | |
| bool | small_add_from (stackvec< size > &vec, limb y, size_t start) noexcept |
| template<uint16_t size> | |
| fastfloat_really_inline bool | small_add (stackvec< size > &vec, limb y) noexcept |
| template<uint16_t size> | |
| bool | small_mul (stackvec< size > &vec, limb y) noexcept |
| template<uint16_t size> | |
| bool | large_add_from (stackvec< size > &x, limb_span y, size_t start) noexcept |
| template<uint16_t size> | |
| fastfloat_really_inline bool | large_add_from (stackvec< size > &x, limb_span y) noexcept |
| template<uint16_t size> | |
| bool | long_mul (stackvec< size > &x, limb_span y) noexcept |
| template<uint16_t size> | |
| bool | large_mul (stackvec< size > &x, limb_span y) noexcept |
| template<int bit_precision> | |
| fastfloat_really_inline value128 | compute_product_approximation (int64_t q, uint64_t w) |
| template<typename binary > | |
| fastfloat_really_inline adjusted_mantissa | compute_error_scaled (int64_t q, uint64_t w, int lz) noexcept |
| template<typename binary > | |
| fastfloat_really_inline adjusted_mantissa | compute_error (int64_t q, uint64_t w) noexcept |
| template<typename binary > | |
| fastfloat_really_inline adjusted_mantissa | compute_float (int64_t q, uint64_t w) noexcept |
| fastfloat_really_inline int32_t | scientific_exponent (parsed_number_string &num) noexcept |
| template<typename T > | |
| fastfloat_really_inline adjusted_mantissa | to_extended (T value) noexcept |
| template<typename T > | |
| fastfloat_really_inline adjusted_mantissa | to_extended_halfway (T value) noexcept |
| template<typename T , typename callback > | |
| fastfloat_really_inline void | round (adjusted_mantissa &am, callback cb) noexcept |
| template<typename callback > | |
| fastfloat_really_inline void | round_nearest_tie_even (adjusted_mantissa &am, int32_t shift, callback cb) noexcept |
| fastfloat_really_inline void | round_down (adjusted_mantissa &am, int32_t shift) noexcept |
| fastfloat_really_inline void | skip_zeros (const char *&first, const char *last) noexcept |
| fastfloat_really_inline bool | is_truncated (const char *first, const char *last) noexcept |
| fastfloat_really_inline bool | is_truncated (byte_span s) noexcept |
| fastfloat_really_inline void | parse_eight_digits (const char *&p, limb &value, size_t &counter, size_t &count) noexcept |
| fastfloat_really_inline void | parse_one_digit (const char *&p, limb &value, size_t &counter, size_t &count) noexcept |
| fastfloat_really_inline void | add_native (bigint &big, limb power, limb value) noexcept |
| fastfloat_really_inline void | round_up_bigint (bigint &big, size_t &count) noexcept |
| void | parse_mantissa (bigint &result, parsed_number_string &num, size_t max_digits, size_t &digits) noexcept |
| template<typename T > | |
| adjusted_mantissa | positive_digit_comp (bigint &bigmant, int32_t exponent) noexcept |
| template<typename T > | |
| adjusted_mantissa | negative_digit_comp (bigint &bigmant, adjusted_mantissa am, int32_t exponent) noexcept |
| template<typename T > | |
| adjusted_mantissa | digit_comp (parsed_number_string &num, adjusted_mantissa am) noexcept |
| template<typename T > | |
| from_chars_result | from_chars (const char *first, const char *last, T &value, chars_format fmt=chars_format::general) noexcept |
| template<typename T > | |
| from_chars_result | from_chars_advanced (const char *first, const char *last, T &value, parse_options options) noexcept |
| bool | fastfloat_strncasecmp (const char *input1, const char *input2, size_t length) |
| fastfloat_really_inline int | leading_zeroes (uint64_t input_num) |
| fastfloat_really_inline value128 | full_multiplication (uint64_t a, uint64_t b) |
| template<typename T > | |
| fastfloat_really_inline void | to_float (bool negative, adjusted_mantissa am, T &value) |
| template<typename binary > | |
| adjusted_mantissa | compute_float (decimal &d) |
| template<typename binary > | |
| adjusted_mantissa | parse_long_mantissa (const char *first, const char *last, parse_options options) |
Variables | |
| constexpr size_t | limb_bits = 32 |
| constexpr size_t | bigint_bits = 4000 |
| constexpr size_t | bigint_limbs = bigint_bits / limb_bits |
| static constexpr uint64_t | powers_of_ten_uint64 [] |
| static constexpr int32_t | invalid_am_bias = -0x8000 |
| static constexpr double | powers_of_ten_double [] |
| static constexpr float | powers_of_ten_float [] |
This code is meant to handle the case where we have more than 19 digits.
It is based on work by Nigel Tao (at https://github.com/google/wuffs/) who credits Ken Thompson for the design (via a reference to the Go source code).
Rob Pike suggested that this algorithm be called "Simple Decimal Conversion".
It is probably not very fast but it is a fallback that should almost never be used in real life. Though it is not fast, it is "easily" understood and debugged.
| typedef span<const char> fast_float::byte_span |
Definition at line 71 of file ascii_number.h.
| typedef uint32_t fast_float::limb |
| typedef span<limb> fast_float::limb_span |
| using fast_float::powers = typedef powers_template<> |
Definition at line 695 of file fast_table.h.
| Enumerator | |
|---|---|
| scientific | |
| fixed | |
| hex | |
| general | |
Definition at line 7 of file fast_float.h.
|
noexcept |
Definition at line 211 of file digit_comparison.h.
References fast_float::detail::power().
Referenced by parse_mantissa(), and round_up_bigint().
| fastfloat_really_inline uint64_t fast_float::byteswap | ( | uint64_t | val | ) |
Definition at line 17 of file ascii_number.h.
Referenced by read_u64(), and write_u64().
|
noexcept |
Definition at line 80 of file decimal_to_binary.h.
References fast_float::value128::high, and leading_zeroes().
|
noexcept |
Definition at line 67 of file decimal_to_binary.h.
References invalid_am_bias, fast_float::adjusted_mantissa::mantissa, fast_float::detail::power(), and fast_float::adjusted_mantissa::power2.
| adjusted_mantissa fast_float::compute_float | ( | decimal & | d | ) |
Definition at line 244 of file simple_decimal_conversion.h.
References fast_float::detail::decimal_left_shift(), fast_float::detail::decimal_right_shift(), fast_float::adjusted_mantissa::mantissa, fast_float::adjusted_mantissa::power2, and fast_float::detail::round().
|
noexcept |
Definition at line 94 of file decimal_to_binary.h.
References fast_float::value128::high, leading_zeroes(), fast_float::value128::low, fast_float::adjusted_mantissa::mantissa, fast_float::detail::power(), and fast_float::adjusted_mantissa::power2.
Referenced by from_chars_advanced().
| fastfloat_really_inline value128 fast_float::compute_product_approximation | ( | int64_t | q, |
| uint64_t | w | ||
| ) |
Definition at line 21 of file decimal_to_binary.h.
References full_multiplication(), fast_float::value128::high, fast_float::value128::low, fast_float::powers_template< unused >::power_of_five_128, and fast_float::powers_template< unused >::smallest_power_of_five.
|
inlinenoexcept |
Definition at line 387 of file digit_comparison.h.
References invalid_am_bias, fast_float::binary_format< T >::max_digits(), parse_mantissa(), fast_float::adjusted_mantissa::power2, and scientific_exponent().
|
noexcept |
Definition at line 158 of file bigint.h.
Referenced by fast_float::bigint::hi64().
|
inline |
Definition at line 94 of file float_common.h.
Referenced by fast_float::detail::parse_infnan().
|
noexcept |
This function parses the character sequence [first,last) for a number. It parses floating-point numbers expecting a locale-indepent format equivalent to what is used by std::strtod in the default ("C") locale. The resulting floating-point value is the closest floating-point values (using either float or double), using the "round to even" convention for values that would otherwise fall right in-between two values. That is, we provide exact parsing according to the IEEE standard.
Given a successful parse, the pointer (ptr) in the returned value is set to point right after the parsed number, and the value referenced is set to the parsed value. In case of error, the returned ec contains a representative error, otherwise the default (std::errc()) value is stored.
The implementation does not throw and does not allocate memory (e.g., with new or malloc).
Like the C++17 standard, the fast_float::from_chars functions take an optional last argument of the type fast_float::chars_format. It is a bitset value: we check whether fmt & fast_float::chars_format::fixed and fmt & fast_float::chars_format::scientific are set to determine whether we allow the fixed point and scientific notation respectively. The default is fast_float::chars_format::general which allows both fixed and scientific.
Definition at line 66 of file parse_number.h.
References from_chars_advanced().
Referenced by StrToCmplx().
|
noexcept |
Like from_chars, but accepts an options argument to govern number parsing.
Definition at line 72 of file parse_number.h.
References compute_float(), fast_float::from_chars_result::ec, fast_float::binary_format< T >::exact_power_of_ten(), fast_float::parsed_number_string::exponent, fast_float::parsed_number_string::lastmatch, fast_float::parsed_number_string::mantissa, fast_float::parsed_number_string::negative, fast_float::detail::parse_infnan(), parse_number_string(), fast_float::adjusted_mantissa::power2, fast_float::from_chars_result::ptr, to_float(), fast_float::parsed_number_string::too_many_digits, and fast_float::parsed_number_string::valid.
Referenced by from_chars().
| fastfloat_really_inline value128 fast_float::full_multiplication | ( | uint64_t | a, |
| uint64_t | b | ||
| ) |
Definition at line 183 of file float_common.h.
References fast_float::value128::high, and fast_float::value128::low.
Referenced by compute_product_approximation(), and scalar_mul().
|
noexcept |
Definition at line 15 of file ascii_number.h.
Referenced by parse_number_string().
|
noexcept |
Definition at line 67 of file ascii_number.h.
References is_made_of_eight_digits_fast(), and read_u64().
|
noexcept |
Definition at line 62 of file ascii_number.h.
Referenced by is_made_of_eight_digits_fast(), and parse_number_string().
|
noexcept |
Definition at line 190 of file digit_comparison.h.
References is_truncated().
|
noexcept |
Definition at line 171 of file digit_comparison.h.
Referenced by is_truncated(), and parse_mantissa().
|
noexcept |
Definition at line 321 of file bigint.h.
References large_add_from().
|
noexcept |
Definition at line 291 of file bigint.h.
References FASTFLOAT_TRY, scalar_add(), and small_add_from().
Referenced by large_add_from(), and long_mul().
Definition at line 355 of file bigint.h.
References FASTFLOAT_TRY, long_mul(), and small_mul().
Referenced by fast_float::bigint::pow5().
| fastfloat_really_inline int fast_float::leading_zeroes | ( | uint64_t | input_num | ) |
Definition at line 133 of file float_common.h.
Referenced by compute_error(), compute_float(), fast_float::bigint::ctlz(), and uint64_hi64().
Definition at line 327 of file bigint.h.
References fast_float::stackvec< size >::data, FASTFLOAT_TRY, large_add_from(), fast_float::stackvec< size >::len(), fast_float::stackvec< size >::set_len(), small_mul(), and fast_float::stackvec< size >::try_extend().
Referenced by large_mul().
|
inlinenoexcept |
Definition at line 327 of file digit_comparison.h.
References fast_float::bigint::compare(), FASTFLOAT_ASSERT, fast_float::adjusted_mantissa::mantissa, fast_float::bigint::pow2(), fast_float::bigint::pow5(), fast_float::adjusted_mantissa::power2, round_down(), round_nearest_tie_even(), to_extended_halfway(), and to_float().
|
noexcept |
Definition at line 195 of file digit_comparison.h.
References parse_eight_digits_unrolled().
Referenced by parse_mantissa().
|
noexcept |
Definition at line 57 of file ascii_number.h.
References parse_eight_digits_unrolled(), and read_u64().
| fastfloat_really_inline uint32_t fast_float::parse_eight_digits_unrolled | ( | uint64_t | val | ) |
Definition at line 47 of file ascii_number.h.
Referenced by parse_eight_digits(), parse_eight_digits_unrolled(), and parse_number_string().
| adjusted_mantissa fast_float::parse_long_mantissa | ( | const char * | first, |
| const char * | last, | ||
| parse_options | options | ||
| ) |
Definition at line 354 of file simple_decimal_conversion.h.
|
inlinenoexcept |
Definition at line 224 of file digit_comparison.h.
References add_native(), is_truncated(), parse_eight_digits(), parse_one_digit(), powers_of_ten_uint64, round_up_bigint(), and skip_zeros().
Referenced by digit_comp().
|
noexcept |
Definition at line 88 of file ascii_number.h.
References fast_float::parsed_number_string::exponent, fixed, fast_float::parsed_number_string::fraction, fast_float::parsed_number_string::integer, is_integer(), is_made_of_eight_digits_fast(), fast_float::parsed_number_string::lastmatch, fast_float::span< T >::len(), fast_float::parsed_number_string::mantissa, fast_float::parsed_number_string::negative, parse_eight_digits_unrolled(), fast_float::span< T >::ptr, scientific, fast_float::parsed_number_string::too_many_digits, and fast_float::parsed_number_string::valid.
Referenced by from_chars_advanced().
|
noexcept |
Definition at line 203 of file digit_comparison.h.
Referenced by parse_mantissa().
|
inlinenoexcept |
Definition at line 304 of file digit_comparison.h.
References FASTFLOAT_ASSERT, fast_float::adjusted_mantissa::mantissa, fast_float::binary_format< T >::mantissa_explicit_bits(), fast_float::binary_format< T >::minimum_exponent(), fast_float::adjusted_mantissa::power2, and round_nearest_tie_even().
| fastfloat_really_inline uint64_t fast_float::read_u64 | ( | const char * | chars | ) |
Definition at line 28 of file ascii_number.h.
References byteswap().
Referenced by is_made_of_eight_digits_fast(), and parse_eight_digits_unrolled().
|
noexcept |
Definition at line 84 of file digit_comparison.h.
References fast_float::binary_format< T >::infinite_power(), and fast_float::binary_format< T >::mantissa_explicit_bits().
|
noexcept |
Definition at line 143 of file digit_comparison.h.
Referenced by negative_digit_comp().
|
noexcept |
Definition at line 114 of file digit_comparison.h.
Referenced by negative_digit_comp(), and positive_digit_comp().
|
noexcept |
Definition at line 216 of file digit_comparison.h.
References add_native().
Referenced by parse_mantissa().
|
noexcept |
Definition at line 208 of file bigint.h.
Referenced by large_add_from(), scalar_mul(), and small_add_from().
|
noexcept |
Definition at line 227 of file bigint.h.
References full_multiplication(), limb_bits, and scalar_add().
Referenced by small_mul().
|
noexcept |
Definition at line 26 of file digit_comparison.h.
Referenced by digit_comp().
|
noexcept |
Definition at line 152 of file digit_comparison.h.
Referenced by parse_mantissa().
|
noexcept |
Definition at line 271 of file bigint.h.
References small_add_from().
Referenced by fast_float::bigint::add().
|
inlinenoexcept |
Definition at line 254 of file bigint.h.
References FASTFLOAT_TRY, and scalar_add().
Referenced by large_add_from(), and small_add().
|
inlinenoexcept |
Definition at line 277 of file bigint.h.
References FASTFLOAT_TRY, and scalar_mul().
Referenced by large_mul(), long_mul(), fast_float::bigint::mul(), and fast_float::bigint::pow5().
|
noexcept |
Definition at line 46 of file digit_comparison.h.
References bits, fast_float::binary_format< T >::exponent_mask(), fast_float::binary_format< T >::hidden_bit_mask(), fast_float::adjusted_mantissa::mantissa, fast_float::binary_format< T >::mantissa_explicit_bits(), fast_float::binary_format< T >::mantissa_mask(), fast_float::binary_format< T >::minimum_exponent(), and fast_float::adjusted_mantissa::power2.
Referenced by to_extended_halfway().
|
noexcept |
Definition at line 74 of file digit_comparison.h.
References fast_float::adjusted_mantissa::mantissa, fast_float::adjusted_mantissa::power2, and to_extended().
Referenced by negative_digit_comp().
| fastfloat_really_inline void fast_float::to_float | ( | bool | negative, |
| adjusted_mantissa | am, | ||
| T & | value | ||
| ) |
Definition at line 377 of file float_common.h.
References fast_float::adjusted_mantissa::mantissa, fast_float::binary_format< T >::mantissa_explicit_bits(), fast_float::adjusted_mantissa::power2, and fast_float::binary_format< T >::sign_index().
Referenced by from_chars_advanced(), and negative_digit_comp().
|
noexcept |
Definition at line 184 of file bigint.h.
References uint64_hi64().
Referenced by fast_float::bigint::hi64().
|
noexcept |
Definition at line 189 of file bigint.h.
References uint64_hi64().
|
noexcept |
Definition at line 196 of file bigint.h.
References uint64_hi64().
|
noexcept |
Definition at line 164 of file bigint.h.
References leading_zeroes().
Referenced by fast_float::bigint::hi64(), and uint32_hi64().
|
noexcept |
Definition at line 171 of file bigint.h.
References leading_zeroes().
| fastfloat_really_inline void fast_float::write_u64 | ( | uint8_t * | chars, |
| uint64_t | val | ||
| ) |
Definition at line 38 of file ascii_number.h.
References byteswap().
|
constexpr |
|
staticconstexpr |
Definition at line 215 of file float_common.h.
Referenced by compute_error_scaled(), and digit_comp().
|
constexpr |
Definition at line 26 of file bigint.h.
Referenced by fast_float::bigint::bit_length(), scalar_mul(), fast_float::bigint::shl(), and fast_float::bigint::shl_bits().
|
staticconstexpr |
Definition at line 217 of file float_common.h.
Referenced by fast_float::binary_format< T >::exact_power_of_ten().
|
staticconstexpr |
Definition at line 220 of file float_common.h.
Referenced by fast_float::binary_format< T >::exact_power_of_ten().
|
staticconstexpr |
Definition at line 16 of file digit_comparison.h.
Referenced by parse_mantissa().