{"id":13437969,"url":"https://github.com/fastfloat/fast_float","last_synced_at":"2025-12-29T18:26:05.841Z","repository":{"id":43086991,"uuid":"305438763","full_name":"fastfloat/fast_float","owner":"fastfloat","description":"Fast and exact implementation of the C++ from_chars functions for number types: 4x to 10x faster than strtod, part of GCC 12, Chromium, Redis and WebKit/Safari","archived":false,"fork":false,"pushed_at":"2025-03-25T13:59:00.000Z","size":996,"stargazers_count":1730,"open_issues_count":19,"forks_count":154,"subscribers_count":41,"default_branch":"main","last_synced_at":"2025-04-10T00:12:34.403Z","etag":null,"topics":["cpp-library","cpp11","cpp17","freebsd","high-performance","linux","macos","neon","simd","sse2","visual-studio"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fastfloat.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE-APACHE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":"AUTHORS","dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-10-19T16:00:53.000Z","updated_at":"2025-04-09T21:54:00.000Z","dependencies_parsed_at":"2024-01-14T09:57:27.366Z","dependency_job_id":"2bd7b42f-6533-4b4e-b434-a484d1d42d5a","html_url":"https://github.com/fastfloat/fast_float","commit_stats":{"total_commits":538,"total_committers":57,"mean_commits":9.43859649122807,"dds":0.6356877323420074,"last_synced_commit":"9ab35254a881e500899222959cde428f7e44d27d"},"previous_names":[],"tags_count":46,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fastfloat%2Ffast_float","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fastfloat%2Ffast_float/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fastfloat%2Ffast_float/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fastfloat%2Ffast_float/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fastfloat","download_url":"https://codeload.github.com/fastfloat/fast_float/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251561900,"owners_count":21609474,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cpp-library","cpp11","cpp17","freebsd","high-performance","linux","macos","neon","simd","sse2","visual-studio"],"created_at":"2024-07-31T03:01:01.811Z","updated_at":"2025-12-29T18:26:05.834Z","avatar_url":"https://github.com/fastfloat.png","language":"C++","readme":"\n## fast_float number parsing library: 4x faster than strtod\n\n[![Ubuntu 22.04 CI (GCC 11)](https://github.com/fastfloat/fast_float/actions/workflows/ubuntu22.yml/badge.svg)](https://github.com/fastfloat/fast_float/actions/workflows/ubuntu22.yml)\n\nThe fast_float library provides fast header-only implementations for the C++\nfrom_chars functions for `float` and `double` types as well as integer types.\nThese functions convert ASCII strings representing decimal values (e.g.,\n`1.3e10`) into binary types. We provide exact rounding (including round to\neven). In our experience, these `fast_float` functions many times faster than\ncomparable number-parsing functions from existing C++ standard libraries.\n\nSpecifically, `fast_float` provides the following two functions to parse\nfloating-point numbers with a C++17-like syntax (the library itself only\nrequires C++11):\n\n```C++\nfrom_chars_result from_chars(char const *first, char const *last, float \u0026value, ...);\nfrom_chars_result from_chars(char const *first, char const *last, double \u0026value, ...);\n```\nIf they are available on your system, we also support fixed-width floating-point types such as `std::float64_t`, `std::float32_t`, `std::float16_t`, and `std::bfloat16_t`.\n\nYou can also parse integer types such as `char`, `short`, `long`, `long long`,  `unsigned char`, `unsigned short`, `unsigned long`, `unsigned long long`, `bool` (0/1),  `int8_t`, `int16_t`, `int32_t`, `int64_t`, `uint8_t`, `uint16_t`, `uint32_t`, `uint64_t`.\n```C++\nfrom_chars_result from_chars(char const *first, char const *last, int \u0026value, ...);\nfrom_chars_result from_chars(char const *first, char const *last, unsigned \u0026value, ...);\n```\n\nThe return type (`from_chars_result`) is defined as the struct:\n\n```C++\nstruct from_chars_result {\n  char const *ptr;\n  std::errc ec;\n};\n```\n\nIt parses the character sequence `[first, last)` for a number. It parses\nfloating-point numbers expecting a locale-independent format equivalent to the\nC++17 from_chars function. The resulting floating-point value is the closest\nfloating-point values (using either `float` or `double`), using the \"round to\neven\" convention for values that would otherwise fall right in-between two\nvalues. That is, we provide exact parsing according to the IEEE standard.\n\nGiven a successful parse, the pointer (`ptr`) in the returned value is set to\npoint right after the parsed number, and the `value` referenced is set to the\nparsed value. In case of error, the returned `ec` contains a representative\nerror, otherwise the default (`std::errc()`) value is stored.\n\nThe implementation does not throw and does not allocate memory (e.g., with `new`\nor `malloc`).\n\nIt will parse infinity and nan values.\n\nExample:\n\n```C++\n#include \"fast_float/fast_float.h\"\n#include \u003ciostream\u003e\n#include \u003cstring\u003e\n\nint main() {\n  std::string input = \"3.1416 xyz \";\n  double result;\n  auto answer = fast_float::from_chars(input.data(), input.data() + input.size(), result);\n  if (answer.ec != std::errc()) { std::cerr \u003c\u003c \"parsing failure\\n\"; return EXIT_FAILURE; }\n  std::cout \u003c\u003c \"parsed the number \" \u003c\u003c result \u003c\u003c std::endl;\n  return EXIT_SUCCESS;\n}\n```\n\nThough the C++17 standard has you do a comparison with `std::errc()` to check whether the conversion worked, you can avoid it by casting the result to a `bool` like so:\n\n```cpp\n#include \"fast_float/fast_float.h\"\n#include \u003ciostream\u003e\n#include \u003cstring\u003e\n\nint main() {\n  std::string input = \"3.1416 xyz \";\n  double result;\n  if(auto answer = fast_float::from_chars(input.data(), input.data() + input.size(), result)) {\n    std::cout \u003c\u003c \"parsed the number \" \u003c\u003c result \u003c\u003c std::endl;\n    return EXIT_SUCCESS;\n  }\n  std::cerr \u003c\u003c \"failed to parse \" \u003c\u003c result \u003c\u003c std::endl;\n  return EXIT_FAILURE;\n}\n```\n\nYou can parse delimited numbers:\n\n```C++\n  std::string input = \"234532.3426362,7869234.9823,324562.645\";\n  double result;\n  auto answer = fast_float::from_chars(input.data(), input.data() + input.size(), result);\n  if (answer.ec != std::errc()) {\n    // check error\n  }\n  // we have result == 234532.3426362.\n  if (answer.ptr[0] != ',') {\n    // unexpected delimiter\n  }\n  answer = fast_float::from_chars(answer.ptr + 1, input.data() + input.size(), result);\n  if (answer.ec != std::errc()) {\n    // check error\n  }\n  // we have result == 7869234.9823.\n  if (answer.ptr[0] != ',') {\n    // unexpected delimiter\n  }\n  answer = fast_float::from_chars(answer.ptr + 1, input.data() + input.size(), result);\n  if (answer.ec != std::errc()) {\n    // check error\n  }\n  // we have result == 324562.645.\n```\n\nLike the C++17 standard, the `fast_float::from_chars` functions take an optional\nlast argument of the type `fast_float::chars_format`. It is a bitset value: we\ncheck whether `fmt \u0026 fast_float::chars_format::fixed` and `fmt \u0026\nfast_float::chars_format::scientific` are set to determine whether we allow the\nfixed point and scientific notation respectively. The default is\n`fast_float::chars_format::general` which allows both `fixed` and `scientific`.\n\nThe library seeks to follow the C++17 (see\n[28.2.3.(6.1)](https://eel.is/c++draft/charconv.from.chars#6.1)) specification.\n\n* The `from_chars` function does not skip leading white-space characters (unless\n  `fast_float::chars_format::skip_white_space` is set).\n* [A leading `+` sign](https://en.cppreference.com/w/cpp/utility/from_chars) is\n  forbidden (unless `fast_float::chars_format::allow_leading_plus` is set).\n* It is generally impossible to represent a decimal value exactly as binary\n  floating-point number (`float` and `double` types). We seek the nearest value.\n  We round to an even mantissa when we are in-between two binary floating-point\n  numbers.\n\nFurthermore, we have the following restrictions:\n\n* We support `float` and `double`, but not `long double`. We also support\n  fixed-width floating-point types such as `std::float64_t`, `std::float32_t`,\n  `std::float16_t`, and `std::bfloat16_t`.\n* We only support the decimal format: we do not support hexadecimal strings.\n* For values that are either very large or very small (e.g., `1e9999`), we\n  represent it using the infinity or negative infinity value and the returned\n  `ec` is set to `std::errc::result_out_of_range`.\n\nWe support Visual Studio, macOS, Linux, freeBSD. We support big and little\nendian. We support 32-bit and 64-bit systems.\n\nWe assume that the rounding mode is set to nearest (`std::fegetround() ==\nFE_TONEAREST`).\n\n## Integer types\n\nYou can also parse integer types using different bases (e.g., 2, 10, 16). The\nfollowing code will print the number 22250738585072012 three times:\n\n```C++\n#include \"fast_float/fast_float.h\"\n#include \u003ciostream\u003e\n\nint main() {\n  uint64_t i;\n  std::string str = \"22250738585072012\";\n  auto answer = fast_float::from_chars(str.data(), str.data() + str.size(), i);\n  if (answer.ec != std::errc()) {\n    std::cerr \u003c\u003c \"parsing failure\\n\";\n    return EXIT_FAILURE;\n  }\n  std::cout \u003c\u003c \"parsed the number \" \u003c\u003c i \u003c\u003c std::endl;\n\n  std::string binstr = \"1001111000011001110110111001001010110100111000110001100\";\n\n  answer = fast_float::from_chars(binstr.data(), binstr.data() + binstr.size(), i, 2);\n  if (answer.ec != std::errc()) {\n    std::cerr \u003c\u003c \"parsing failure\\n\";\n    return EXIT_FAILURE;\n  }\n  std::cout \u003c\u003c \"parsed the number \" \u003c\u003c i \u003c\u003c std::endl;\n\n  std::string hexstr = \"4f0cedc95a718c\";\n\n  answer = fast_float::from_chars(hexstr.data(), hexstr.data() + hexstr.size(), i, 16);\n  if (answer.ec != std::errc()) {\n    std::cerr \u003c\u003c \"parsing failure\\n\";\n    return EXIT_FAILURE;\n  }\n  std::cout \u003c\u003c \"parsed the number \" \u003c\u003c i \u003c\u003c std::endl;\n  return EXIT_SUCCESS;\n}\n```\n\n## Behavior of result_out_of_range\n\nWhen parsing floating-point values, the numbers can sometimes be too small\n(e.g., `1e-1000`) or too large (e.g., `1e1000`). The C language established the\nprecedent that these small values are out of range. In such cases, it is\ncustomary to parse small values to zero and large values to infinity. That is\nthe behaviour of the C language (e.g., `stdtod`). That is the behaviour followed\nby the fast_float library.\n\nSpecifically, we follow Jonathan Wakely's interpretation of the standard:\n\n\u003e In any case, the resulting value is one of at most two floating-point values\n\u003e closest to the value of the string matching the pattern.\n\nIt is also the approach taken by the [Microsoft C++\nlibrary](https://github.com/microsoft/STL/blob/62205ab155d093e71dd9588a78f02c5396c3c14b/tests/std/tests/P0067R5_charconv/test.cpp#L943-L946).\n\nHence, we have the following examples:\n\n```cpp\n  double result = -1;\n  std::string str = \"3e-1000\";\n  auto r = fast_float::from_chars(str.data(), str.data() + str.size(), result);\n  // r.ec == std::errc::result_out_of_range\n  // r.ptr == str.data() + 7\n  // result == 0\n```\n\n```cpp\n  double result = -1;\n  std::string str = \"3e1000\";\n  auto r = fast_float::from_chars(str.data(), str.data() + str.size(), result);\n  // r.ec == std::errc::result_out_of_range\n  // r.ptr == str.data() + 6\n  // result == std::numeric_limits\u003cdouble\u003e::infinity()\n```\n\nUsers who wish for the value to be left unmodified given\n`std::errc::result_out_of_range` may do so by adding two lines of code:\n\n```cpp\n  double old_result = result; // make copy\n  auto r = fast_float::from_chars(start, end, result);\n  if (r.ec == std::errc::result_out_of_range) { result = old_result; }\n```\n\n## C++20: compile-time evaluation (constexpr)\n\nIn C++20, you may use `fast_float::from_chars` to parse strings at compile-time,\nas in the following example:\n\n```C++\n// consteval forces compile-time evaluation of the function in C++20.\nconsteval double parse(std::string_view input) {\n  double result;\n  auto answer = fast_float::from_chars(input.data(), input.data() + input.size(), result);\n  if (answer.ec != std::errc()) { return -1.0; }\n  return result;\n}\n\n// This function should compile to a function which\n// merely returns 3.1415.\nconstexpr double constexptest() {\n  return parse(\"3.1415 input\");\n}\n```\n\n## C++23: Fixed width floating-point types\n\nThe library also supports fixed-width floating-point types such as\n`std::float64_t`, `std::float32_t`, `std::float16_t`, and `std::bfloat16_t`.\nE.g., you can write:\n\n```C++\nstd::float32_t result;\nauto answer = fast_float::from_chars(f.data(), f.data() + f.size(), result);\n```\n\n## Non-ASCII Inputs\n\nWe also support UTF-16 and UTF-32 inputs, as well as ASCII/UTF-8, as in the\nfollowing example:\n\n```C++\n#include \"fast_float/fast_float.h\"\n#include \u003ciostream\u003e\n\nint main() {\n  std::u16string input = u\"3.1416 xyz \";\n  double result;\n  auto answer = fast_float::from_chars(input.data(), input.data() + input.size(), result);\n  if (answer.ec != std::errc()) { std::cerr \u003c\u003c \"parsing failure\\n\"; return EXIT_FAILURE; }\n  std::cout \u003c\u003c \"parsed the number \" \u003c\u003c result \u003c\u003c std::endl;\n  return EXIT_SUCCESS;\n}\n```\n\n## Advanced options: using commas as decimal separator, JSON and Fortran\n\nThe C++ standard stipulate that `from_chars` has to be locale-independent. In\nparticular, the decimal separator has to be the period (`.`). However, some\nusers still want to use the `fast_float` library with in a locale-dependent\nmanner. Using a separate function called `from_chars_advanced`, we allow the\nusers to pass a `parse_options` instance which contains a custom decimal\nseparator (e.g., the comma). You may use it as follows.\n\n```C++\n#include \"fast_float/fast_float.h\"\n#include \u003ciostream\u003e\n\nint main() {\n  std::string input = \"3,1416 xyz \";\n  double result;\n  fast_float::parse_options options{fast_float::chars_format::general, ','};\n  auto answer = fast_float::from_chars_advanced(input.data(), input.data() + input.size(), result, options);\n  if ((answer.ec != std::errc()) || ((result != 3.1416))) { std::cerr \u003c\u003c \"parsing failure\\n\"; return EXIT_FAILURE; }\n  std::cout \u003c\u003c \"parsed the number \" \u003c\u003c result \u003c\u003c std::endl;\n  return EXIT_SUCCESS;\n}\n```\n\n### You can also parse Fortran-like inputs\n\n```C++\n#include \"fast_float/fast_float.h\"\n#include \u003ciostream\u003e\n\nint main() {\n  std::string input = \"1d+4\";\n  double result;\n  fast_float::parse_options options{fast_float::chars_format::fortran};\n  auto answer = fast_float::from_chars_advanced(input.data(), input.data() + input.size(), result, options);\n  if ((answer.ec != std::errc()) || ((result != 10000))) { std::cerr \u003c\u003c \"parsing failure\\n\"; return EXIT_FAILURE; }\n  std::cout \u003c\u003c \"parsed the number \" \u003c\u003c result \u003c\u003c std::endl;\n  return EXIT_SUCCESS;\n}\n```\n\n### You may also enforce the JSON format ([RFC 8259](https://datatracker.ietf.org/doc/html/rfc8259#section-6))\n\n```C++\n#include \"fast_float/fast_float.h\"\n#include \u003ciostream\u003e\n\nint main() {\n  std::string input = \"+.1\"; // not valid\n  double result;\n  fast_float::parse_options options{fast_float::chars_format::json};\n  auto answer = fast_float::from_chars_advanced(input.data(), input.data() + input.size(), result, options);\n  if (answer.ec == std::errc()) { std::cerr \u003c\u003c \"should have failed\\n\"; return EXIT_FAILURE; }\n  return EXIT_SUCCESS;\n}\n```\n\nBy default the JSON format does not allow `inf`:\n\n```C++\n#include \"fast_float/fast_float.h\"\n#include \u003ciostream\u003e\n\nint main() {\n  std::string input = \"inf\"; // not valid in JSON\n  double result;\n  fast_float::parse_options options{fast_float::chars_format::json};\n  auto answer = fast_float::from_chars_advanced(input.data(), input.data() + input.size(), result, options);\n  if (answer.ec == std::errc()) { std::cerr \u003c\u003c \"should have failed\\n\"; return EXIT_FAILURE; }\n  return EXIT_SUCCESS;\n}\n```\n\nYou can allow it with a non-standard `json_or_infnan` variant:\n\n```C++\n#include \"fast_float/fast_float.h\"\n#include \u003ciostream\u003e\n\nint main() {\n  std::string input = \"inf\"; // not valid in JSON but we allow it with json_or_infnan\n  double result;\n  fast_float::parse_options options{fast_float::chars_format::json_or_infnan};\n  auto answer = fast_float::from_chars_advanced(input.data(), input.data() + input.size(), result, options);\n  if (answer.ec != std::errc() || (!std::isinf(result))) { std::cerr \u003c\u003c \"should have parsed infinity\\n\"; return EXIT_FAILURE; }\n  return EXIT_SUCCESS;\n}\n```\n\n## Multiplication of an integer by a power of 10\nAn integer `W` can be multiplied by a power of ten `10^Q` and\nconverted to `double` with correctly rounded value\n(in \"round to nearest, tie to even\" fashion) using\n`fast_float::integer_times_pow10()`, e.g.:\n```C++\nconst uint64_t W = 12345678901234567;\nconst int Q = 23;\nconst double result = fast_float::integer_times_pow10(W, Q);\nstd::cout.precision(17);\nstd::cout \u003c\u003c W \u003c\u003c \" * 10^\" \u003c\u003c Q \u003c\u003c \" = \" \u003c\u003c result \u003c\u003c \" (\"\n  \u003c\u003c (result == 12345678901234567e23 ? \"==\" : \"!=\") \u003c\u003c \"expected)\\n\";\n```\noutputs\n```\n12345678901234567 * 10^23 = 1.2345678901234567e+39 (==expected)\n```\n`fast_float::integer_times_pow10()` gives the same result as\nusing `fast_float::from_chars()` when parsing the string `\"WeQ\"`\n(in this example `\"12345678901234567e23\"`),\nexcept `fast_float::integer_times_pow10()` does not report out-of-range errors, and\nunderflows to zero or overflows to infinity when the resulting value is\nout of range.\n\nYou can use template overloads to get the result converted to different\nsupported floating-point types: `float`, `double`, etc.\nFor example, to get result as `float` use\n`fast_float::integer_times_pow10\u003cfloat\u003e()` specialization:\n```C++\nconst uint64_t W = 12345678;\nconst int Q = 23;\nconst float result = fast_float::integer_times_pow10\u003cfloat\u003e(W, Q);\nstd::cout.precision(9);\nstd::cout \u003c\u003c \"float: \" \u003c\u003c W \u003c\u003c \" * 10^\" \u003c\u003c Q \u003c\u003c \" = \" \u003c\u003c result \u003c\u003c \" (\"\n          \u003c\u003c (result == 12345678e23f ? \"==\" : \"!=\") \u003c\u003c \"expected)\\n\";\n```\noutputs\n```\nfloat: 12345678 * 10^23 = 1.23456782e+30 (==expected)\n```\n\nOverloads of `fast_float::integer_times_pow10()` are provided for\nsigned and unsigned integer types: `int64_t`, `uint64_t`, etc.\n\n\n## Users and Related Work\n\nThe fast_float library is part of:\n\n* GCC (as of version 12): the `from_chars` function in GCC relies on fast_float,\n* [Chromium](https://github.com/Chromium/Chromium), the engine behind Google\n  Chrome, Microsoft Edge, and Opera,\n* Boost JSON, MySQL, etc.\n* Blender\n* [WebKit](https://github.com/WebKit/WebKit), the engine behind Safari (Apple's\n  web browser),\n* [DuckDB](https://duckdb.org),\n* [Redis](https://github.com/redis/redis) and [Valkey](https://github.com/valkey-io/valkey),\n* [Apache Arrow](https://github.com/apache/arrow/pull/8494) where it multiplied\n  the number parsing speed by two or three times,\n* [Google Jsonnet](https://github.com/google/jsonnet),\n* [ClickHouse](https://github.com/ClickHouse/ClickHouse).\n\nThe fastfloat algorithm is part of the [LLVM standard\nlibraries](https://github.com/llvm/llvm-project/commit/87c016078ad72c46505461e4ff8bfa04819fe7ba).\nThere is a [derived implementation part of\nAdaCore](https://github.com/AdaCore/VSS). The [SerenityOS operating\nsystem](https://github.com/SerenityOS/serenity/commit/53b7f5e6a11e663c83df8030c3171c5945cb75ec)\nhas a derived implementation that is inherited by the [Ladybird\nBrowser](https://github.com/LadybirdBrowser/ladybird).\n\nThe fast_float library provides a performance similar to that of the\n[fast_double_parser](https://github.com/lemire/fast_double_parser) library but\nusing an updated algorithm reworked from the ground up, and while offering an\nAPI more in line with the expectations of C++ programmers. The\nfast_double_parser library is part of the [Microsoft LightGBM machine-learning\nframework](https://github.com/microsoft/LightGBM).\n\n\n\nPackages\n------\n\n[![Packaging status](https://repology.org/badge/vertical-allrepos/fast-float.svg)](https://repology.org/project/fast-float/versions)\n\n\n## References\n\n* Daniel Lemire, [Number Parsing at a Gigabyte per\n  Second](https://arxiv.org/abs/2101.11408), Software: Practice and Experience\n  51 (8), 2021.\n* Noble Mushtak, Daniel Lemire, [Fast Number Parsing Without\n  Fallback](https://arxiv.org/abs/2212.06644), Software: Practice and Experience\n  53 (7), 2023.\n\n## Other programming languages\n\n* [There is an R binding](https://github.com/eddelbuettel/rcppfastfloat) called\n  `rcppfastfloat`.\n* [There is a Rust port of the fast_float\n  library](https://github.com/aldanor/fast-float-rust/) called\n  `fast-float-rust`.\n* [There is a Java port of the fast_float\n  library](https://github.com/wrandelshofer/FastDoubleParser) called\n  `FastDoubleParser`. It used for important systems such as\n  [Jackson](https://github.com/FasterXML/jackson-core).\n* [There is a C# port of the fast_float\n  library](https://github.com/CarlVerret/csFastFloat) called `csFastFloat`.\n\n## How fast is it?\n\nIt can parse random floating-point numbers at a speed of 1 GB/s on some systems.\nWe find that it is often twice as fast as the best available competitor, and\nmany times faster than many standard-library implementations.\n\n\u003cimg src=\"https://lemire.me/blog/wp-content/uploads/2020/11/fastfloat_speed.png\"\nwidth=\"400\" alt=\"fast_float is many times faster than many standard-library\nimplementations\"\u003e\n\n```bash\n$ ./build/benchmarks/benchmark\n# parsing random integers in the range [0,1)\nvolume = 2.09808 MB\nnetlib                                  :   271.18 MB/s (+/- 1.2 %)    12.93 Mfloat/s\ndoubleconversion                        :   225.35 MB/s (+/- 1.2 %)    10.74 Mfloat/s\nstrtod                                  :   190.94 MB/s (+/- 1.6 %)     9.10 Mfloat/s\nabseil                                  :   430.45 MB/s (+/- 2.2 %)    20.52 Mfloat/s\nfastfloat                               :  1042.38 MB/s (+/- 9.9 %)    49.68 Mfloat/s\n```\n\nSee the [Benchmarking](#benchmarking) section for instructions on how to run our benchmarks.\n\n## Video\n\n[![Go Systems 2020](https://img.youtube.com/vi/AVXgvlMeIm4/0.jpg)](https://www.youtube.com/watch?v=AVXgvlMeIm4)\n\n## Using as a CMake dependency\n\nThis library is header-only by design. The CMake file provides the `fast_float`\ntarget which is merely a pointer to the `include` directory.\n\nIf you drop the `fast_float` repository in your CMake project, you should be\nable to use it in this manner:\n\n```cmake\nadd_subdirectory(fast_float)\ntarget_link_libraries(myprogram PUBLIC fast_float)\n```\n\nOr you may want to retrieve the dependency automatically if you have a\nsufficiently recent version of CMake (3.11 or better at least):\n\n```cmake\nFetchContent_Declare(\n  fast_float\n  GIT_REPOSITORY https://github.com/fastfloat/fast_float.git\n  GIT_TAG tags/v8.2.1\n  GIT_SHALLOW TRUE)\n\nFetchContent_MakeAvailable(fast_float)\ntarget_link_libraries(myprogram PUBLIC fast_float)\n```\n\nYou should change the `GIT_TAG` line so that you recover the version you wish to\nuse.\n\nYou may also use [CPM](https://github.com/cpm-cmake/CPM.cmake), like so:\n\n```cmake\nCPMAddPackage(\n  NAME fast_float\n  GITHUB_REPOSITORY \"fastfloat/fast_float\"\n  GIT_TAG v8.2.1)\n```\n\n## Using as single header\n\nThe script `script/amalgamate.py` may be used to generate a single header\nversion of the library if so desired. Just run the script from the root\ndirectory of this repository. You can customize the license type and output file\nif desired as described in the command line help.\n\nYou may directly download automatically generated single-header files:\n\n\u003chttps://github.com/fastfloat/fast_float/releases/download/v8.2.1/fast_float.h\u003e\n\n## Benchmarking\n\nThe project has its own benchmarks with realistic data inputs. Under Linux or macOS,\nyou can use it as follows if your system supports C++17:\n\n```\ncmake -B build -D FASTFLOAT_BENCHMARKS=ON\ncmake --build build\n./build/benchmarks/realbenchmark\n```\n\nImportantly, by default, the benchmark is built in Release mode.\n\nThe instructions are similar under Windows.\n\nUnder Linux and macOS, it is recommended to run the benchmarks in a privileged manner to get access\nto hardware performance counters. You may be able to do so with the `sudo` command\nin some cases:\n\n```\nsudo ./build/benchmarks/realbenchmark\n```\n\nIf you have a text file containing one number per line (`myfile.txt`), you can run a benchmark over it like so:\n```\ncmake -B build -D FASTFLOAT_BENCHMARKS=ON\ncmake --build build\n./build/benchmarks/realbenchmark myfile.txt\n```\n\n\n## Packages\n\n* The fast_float library is part of the [Conan package\n  manager](https://conan.io/center/recipes/fast_float).\n* It is part of the [brew package\n  manager](https://formulae.brew.sh/formula/fast_float).\n* fast_float is available on [xmake](https://xmake.io) repository.\n* Some Linux distribution like Fedora include fast_float (e.g., as\n  `fast_float-devel`).\n\n## Credit\n\nThough this work is inspired by many different people, this work benefited\nespecially from exchanges with Michael Eisel, who motivated the original\nresearch with his key insights, and with Nigel Tao who provided invaluable\nfeedback. Rémy Oudompheng first implemented a fast path we use in the case of\nlong digits.\n\nThe library includes code adapted from Google Wuffs (written by Nigel Tao) which\nwas originally published under the Apache 2.0 license.\n\n## Stars\n\n\n[![Star History Chart](https://api.star-history.com/svg?repos=fastfloat/fast_float\u0026type=Date)](https://www.star-history.com/#fastfloat/fast_float\u0026Date)\n\n## License\n\n\u003csup\u003e\nLicensed under either of \u003ca href=\"LICENSE-APACHE\"\u003eApache License, Version\n2.0\u003c/a\u003e or \u003ca href=\"LICENSE-MIT\"\u003eMIT license\u003c/a\u003e or \u003ca\nhref=\"LICENSE-BOOST\"\u003eBOOST license\u003c/a\u003e.\n\u003c/sup\u003e\n\n\u003cbr/\u003e\n\n\u003csub\u003e\nUnless you explicitly state otherwise, any contribution intentionally submitted\nfor inclusion in this repository by you, as defined in the Apache-2.0 license,\nshall be triple licensed as above, without any additional terms or conditions.\n\u003c/sub\u003e\n","funding_links":[],"categories":["Miscellaneous","HarmonyOS","C++","Libraries"],"sub_categories":["Windows Manager"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffastfloat%2Ffast_float","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffastfloat%2Ffast_float","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffastfloat%2Ffast_float/lists"}