mirror of
https://github.com/fastfloat/fast_float.git
synced 2025-12-07 01:06:48 +08:00
Merge pull request #24 from kitaisreal/fix-odr
Fixed odr with inlining and anonymous namespace
This commit is contained in:
commit
045a0b0447
@ -10,7 +10,7 @@
|
|||||||
|
|
||||||
namespace fast_float {
|
namespace fast_float {
|
||||||
|
|
||||||
fastfloat_really_inline bool is_integer(char c) noexcept { return (c >= '0' && c <= '9'); }
|
fastfloat_really_inline bool is_integer(char c) noexcept { return (c & 0x30) == 0x30; }
|
||||||
|
|
||||||
|
|
||||||
// credit: https://johnnylee-sde.github.io/Fast-numeric-string-to-int/
|
// credit: https://johnnylee-sde.github.io/Fast-numeric-string-to-int/
|
||||||
@ -163,7 +163,7 @@ parsed_number_string parse_number_string(const char *p, const char *pend, chars_
|
|||||||
// This function could be optimized. In particular, we could stop after 19 digits
|
// This function could be optimized. In particular, we could stop after 19 digits
|
||||||
// and try to bail out. Furthermore, we should be able to recover the computed
|
// and try to bail out. Furthermore, we should be able to recover the computed
|
||||||
// exponent from the pass in parse_number_string.
|
// exponent from the pass in parse_number_string.
|
||||||
decimal parse_decimal(const char *p, const char *pend) noexcept {
|
fastfloat_really_inline decimal parse_decimal(const char *p, const char *pend) noexcept {
|
||||||
decimal answer;
|
decimal answer;
|
||||||
answer.num_digits = 0;
|
answer.num_digits = 0;
|
||||||
answer.decimal_point = 0;
|
answer.decimal_point = 0;
|
||||||
|
|||||||
@ -30,7 +30,7 @@ inline bool fastfloat_strncasecmp(const char *input1, const char *input2,
|
|||||||
#error "FLT_EVAL_METHOD should be defined, please include cfloat."
|
#error "FLT_EVAL_METHOD should be defined, please include cfloat."
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
bool is_space(uint8_t c) {
|
inline bool is_space(uint8_t c) {
|
||||||
static const bool table[] = {
|
static const bool table[] = {
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
@ -281,7 +281,7 @@ constexpr float binary_format<float>::exact_power_of_ten(int64_t power) {
|
|||||||
|
|
||||||
// for convenience:
|
// for convenience:
|
||||||
#include <ostream>
|
#include <ostream>
|
||||||
std::ostream &operator<<(std::ostream &out, const fast_float::decimal &d) {
|
inline std::ostream &operator<<(std::ostream &out, const fast_float::decimal &d) {
|
||||||
out << "0.";
|
out << "0.";
|
||||||
for (size_t i = 0; i < d.num_digits; i++) {
|
for (size_t i = 0; i < d.num_digits; i++) {
|
||||||
out << int32_t(d.digits[i]);
|
out << int32_t(d.digits[i]);
|
||||||
|
|||||||
@ -123,8 +123,6 @@ uint32_t number_of_digits_decimal_left_shift(const decimal &h, uint32_t shift) {
|
|||||||
return num_new_digits;
|
return num_new_digits;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // end of anonymous namespace
|
|
||||||
|
|
||||||
uint64_t round(decimal &h) {
|
uint64_t round(decimal &h) {
|
||||||
if ((h.num_digits == 0) || (h.decimal_point < 0)) {
|
if ((h.num_digits == 0) || (h.decimal_point < 0)) {
|
||||||
return 0;
|
return 0;
|
||||||
@ -240,6 +238,7 @@ void decimal_right_shift(decimal &h, uint32_t shift) {
|
|||||||
trim(h);
|
trim(h);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // end of anonymous namespace
|
||||||
|
|
||||||
template <typename binary>
|
template <typename binary>
|
||||||
adjusted_mantissa compute_float(decimal &d) {
|
adjusted_mantissa compute_float(decimal &d) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user