mirror of
https://github.com/fastfloat/fast_float.git
synced 2026-04-30 19:09:19 +08:00
Compare commits
26 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
05087a303d | ||
|
|
b2b1e203ba | ||
|
|
b57ec064ad | ||
|
|
001c04cc8a | ||
|
|
b063de82c7 | ||
|
|
d7ad33a80e | ||
|
|
2027a39ba0 | ||
|
|
9817d5ddaa | ||
|
|
7124634005 | ||
|
|
419695eba6 | ||
|
|
18e55e48a8 | ||
|
|
eb9ab42c0a | ||
|
|
50c19fad17 | ||
|
|
3f42ad2272 | ||
|
|
00fb4f4b1e | ||
|
|
2606bcdf2f | ||
|
|
b83fdd79ce | ||
|
|
a18b614b0e | ||
|
|
8514abe2e2 | ||
|
|
9f30728ce9 | ||
|
|
3c6a64b87d | ||
|
|
221a4920db | ||
|
|
a110aa1392 | ||
|
|
8d9f627710 | ||
|
|
3e2b5d3dc3 | ||
|
|
f43d6711bc |
24
.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
24
.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
---
|
||||||
|
name: Bug report
|
||||||
|
about: Create a report to help us improve
|
||||||
|
title: ''
|
||||||
|
labels: ''
|
||||||
|
assignees: ''
|
||||||
|
---
|
||||||
|
|
||||||
|
**Describe the bug**
|
||||||
|
A clear and concise description of what the bug is.
|
||||||
|
|
||||||
|
**To Reproduce**
|
||||||
|
Ideally, you should provide a reproducible test case.
|
||||||
|
|
||||||
|
**Expected behavior**
|
||||||
|
A clear and concise description of what you expected to happen.
|
||||||
|
|
||||||
|
**Additional context**
|
||||||
|
Add any other context about the problem here.
|
||||||
|
|
||||||
|
**Note:** Bug reports should come with a test case or, at least, an analysis.
|
||||||
|
|
||||||
|
**Automated tool policy**: If you use an automated tool (e.g., static analysis,
|
||||||
|
LLM, etc.), you need to demonstrate an understanding of the issue you are raising. Usually, a bug is demonstrated by a test case. Do not copy-paste what a tool is telling you.
|
||||||
2
.github/workflows/cifuzz.yml
vendored
2
.github/workflows/cifuzz.yml
vendored
@ -20,7 +20,7 @@ jobs:
|
|||||||
fuzz-seconds: 300
|
fuzz-seconds: 300
|
||||||
output-sarif: true
|
output-sarif: true
|
||||||
- name: Upload Crash
|
- name: Upload Crash
|
||||||
uses: actions/upload-artifact@v6
|
uses: actions/upload-artifact@v7
|
||||||
if: failure() && steps.build.outcome == 'success'
|
if: failure() && steps.build.outcome == 'success'
|
||||||
with:
|
with:
|
||||||
name: artifacts
|
name: artifacts
|
||||||
|
|||||||
2
.github/workflows/emscripten.yml
vendored
2
.github/workflows/emscripten.yml
vendored
@ -5,7 +5,7 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@0c366fd6a839edf440554fa01a7085ccba70ac98 # v4.2.2
|
- uses: actions/checkout@0c366fd6a839edf440554fa01a7085ccba70ac98 # v4.2.2
|
||||||
- uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0
|
- uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
|
||||||
- uses: mymindstorm/setup-emsdk@6ab9eb1bda2574c4ddb79809fc9247783eaf9021 # v14
|
- uses: mymindstorm/setup-emsdk@6ab9eb1bda2574c4ddb79809fc9247783eaf9021 # v14
|
||||||
- name: Verify
|
- name: Verify
|
||||||
run: emcc -v
|
run: emcc -v
|
||||||
|
|||||||
2
.github/workflows/lint_and_format_check.yml
vendored
2
.github/workflows/lint_and_format_check.yml
vendored
@ -27,7 +27,7 @@ jobs:
|
|||||||
- uses: actions/checkout@0c366fd6a839edf440554fa01a7085ccba70ac98 # v4.1.7
|
- uses: actions/checkout@0c366fd6a839edf440554fa01a7085ccba70ac98 # v4.1.7
|
||||||
|
|
||||||
- name: Run clang-format
|
- name: Run clang-format
|
||||||
uses: jidicula/clang-format-action@6cd220de46c89139a0365edae93eee8eb30ca8fe # v4.16.0
|
uses: jidicula/clang-format-action@3a18028048f01a66653b4e3bf8d968d2e7e2cb8b # v4.17.0
|
||||||
with:
|
with:
|
||||||
clang-format-version: '17'
|
clang-format-version: '17'
|
||||||
|
|
||||||
|
|||||||
3
.github/workflows/msys2-clang.yml
vendored
3
.github/workflows/msys2-clang.yml
vendored
@ -16,9 +16,6 @@ jobs:
|
|||||||
- msystem: "MINGW64"
|
- msystem: "MINGW64"
|
||||||
install: mingw-w64-x86_64-libxml2 mingw-w64-x86_64-cmake mingw-w64-x86_64-ninja mingw-w64-x86_64-clang
|
install: mingw-w64-x86_64-libxml2 mingw-w64-x86_64-cmake mingw-w64-x86_64-ninja mingw-w64-x86_64-clang
|
||||||
type: Release
|
type: Release
|
||||||
- msystem: "MINGW32"
|
|
||||||
install: mingw-w64-i686-libxml2 mingw-w64-i686-cmake mingw-w64-i686-ninja mingw-w64-i686-clang
|
|
||||||
type: Release
|
|
||||||
env:
|
env:
|
||||||
CMAKE_GENERATOR: Ninja
|
CMAKE_GENERATOR: Ninja
|
||||||
|
|
||||||
|
|||||||
6
.github/workflows/msys2.yml
vendored
6
.github/workflows/msys2.yml
vendored
@ -16,15 +16,9 @@ jobs:
|
|||||||
- msystem: "MINGW64"
|
- msystem: "MINGW64"
|
||||||
install: mingw-w64-x86_64-cmake mingw-w64-x86_64-ninja mingw-w64-x86_64-gcc
|
install: mingw-w64-x86_64-cmake mingw-w64-x86_64-ninja mingw-w64-x86_64-gcc
|
||||||
type: Release
|
type: Release
|
||||||
- msystem: "MINGW32"
|
|
||||||
install: mingw-w64-i686-cmake mingw-w64-i686-ninja mingw-w64-i686-gcc
|
|
||||||
type: Release
|
|
||||||
- msystem: "MINGW64"
|
- msystem: "MINGW64"
|
||||||
install: mingw-w64-x86_64-cmake mingw-w64-x86_64-ninja mingw-w64-x86_64-gcc
|
install: mingw-w64-x86_64-cmake mingw-w64-x86_64-ninja mingw-w64-x86_64-gcc
|
||||||
type: Debug
|
type: Debug
|
||||||
- msystem: "MINGW32"
|
|
||||||
install: mingw-w64-i686-cmake mingw-w64-i686-ninja mingw-w64-i686-gcc
|
|
||||||
type: Debug
|
|
||||||
env:
|
env:
|
||||||
CMAKE_GENERATOR: Ninja
|
CMAKE_GENERATOR: Ninja
|
||||||
|
|
||||||
|
|||||||
@ -1,3 +1,5 @@
|
|||||||
|
load("@rules_cc//cc:cc_library.bzl", "cc_library")
|
||||||
|
|
||||||
cc_library(
|
cc_library(
|
||||||
name = "fast_float",
|
name = "fast_float",
|
||||||
hdrs = glob(["include/fast_float/*.h"]),
|
hdrs = glob(["include/fast_float/*.h"]),
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
cmake_minimum_required(VERSION 3.14)
|
cmake_minimum_required(VERSION 3.14)
|
||||||
|
|
||||||
|
|
||||||
project(fast_float VERSION 8.2.3 LANGUAGES CXX)
|
project(fast_float VERSION 8.2.5 LANGUAGES CXX)
|
||||||
set(FASTFLOAT_CXX_STANDARD 11 CACHE STRING "the C++ standard to use for fastfloat")
|
set(FASTFLOAT_CXX_STANDARD 11 CACHE STRING "the C++ standard to use for fastfloat")
|
||||||
set(CMAKE_CXX_STANDARD ${FASTFLOAT_CXX_STANDARD})
|
set(CMAKE_CXX_STANDARD ${FASTFLOAT_CXX_STANDARD})
|
||||||
option(FASTFLOAT_TEST "Enable tests" OFF)
|
option(FASTFLOAT_TEST "Enable tests" OFF)
|
||||||
|
|||||||
@ -2,8 +2,10 @@
|
|||||||
|
|
||||||
module(
|
module(
|
||||||
name = "fast_float",
|
name = "fast_float",
|
||||||
version = "6.1.6",
|
version = "8.2.4",
|
||||||
compatibility_level = 6,
|
compatibility_level = 8,
|
||||||
)
|
)
|
||||||
|
|
||||||
bazel_dep(name = "doctest", version = "2.4.11", dev_dependency = True)
|
bazel_dep(name = "doctest", version = "2.4.11", dev_dependency = True)
|
||||||
|
|
||||||
|
bazel_dep(name = "rules_cc", version = "0.2.17")
|
||||||
|
|||||||
11
README.md
11
README.md
@ -3,6 +3,9 @@
|
|||||||
|
|
||||||
[](https://github.com/fastfloat/fast_float/actions/workflows/ubuntu22.yml)
|
[](https://github.com/fastfloat/fast_float/actions/workflows/ubuntu22.yml)
|
||||||
|
|
||||||
|
*Note: This library is for C++ users. C programmers should consider [ffc.h](https://github.com/kolemannix/ffc.h). It is a high-performance port of fast_float to C.*
|
||||||
|
|
||||||
|
|
||||||
The fast_float library provides fast header-only implementations for the C++
|
The fast_float library provides fast header-only implementations for the C++
|
||||||
from_chars functions for `float` and `double` types as well as integer types.
|
from_chars functions for `float` and `double` types as well as integer types.
|
||||||
These functions convert ASCII strings representing decimal values (e.g.,
|
These functions convert ASCII strings representing decimal values (e.g.,
|
||||||
@ -10,6 +13,7 @@ These functions convert ASCII strings representing decimal values (e.g.,
|
|||||||
even). In our experience, these `fast_float` functions many times faster than
|
even). In our experience, these `fast_float` functions many times faster than
|
||||||
comparable number-parsing functions from existing C++ standard libraries.
|
comparable number-parsing functions from existing C++ standard libraries.
|
||||||
|
|
||||||
|
|
||||||
Specifically, `fast_float` provides the following two functions to parse
|
Specifically, `fast_float` provides the following two functions to parse
|
||||||
floating-point numbers with a C++17-like syntax (the library itself only
|
floating-point numbers with a C++17-like syntax (the library itself only
|
||||||
requires C++11):
|
requires C++11):
|
||||||
@ -488,6 +492,7 @@ Packages
|
|||||||
[Jackson](https://github.com/FasterXML/jackson-core).
|
[Jackson](https://github.com/FasterXML/jackson-core).
|
||||||
* [There is a C# port of the fast_float
|
* [There is a C# port of the fast_float
|
||||||
library](https://github.com/CarlVerret/csFastFloat) called `csFastFloat`.
|
library](https://github.com/CarlVerret/csFastFloat) called `csFastFloat`.
|
||||||
|
* [There is a plain C port of the fast_float library](https://github.com/kolemannix/ffc.h) called ffc.h
|
||||||
|
|
||||||
## How fast is it?
|
## How fast is it?
|
||||||
|
|
||||||
@ -536,7 +541,7 @@ sufficiently recent version of CMake (3.11 or better at least):
|
|||||||
FetchContent_Declare(
|
FetchContent_Declare(
|
||||||
fast_float
|
fast_float
|
||||||
GIT_REPOSITORY https://github.com/fastfloat/fast_float.git
|
GIT_REPOSITORY https://github.com/fastfloat/fast_float.git
|
||||||
GIT_TAG tags/v8.2.3
|
GIT_TAG tags/v8.2.5
|
||||||
GIT_SHALLOW TRUE)
|
GIT_SHALLOW TRUE)
|
||||||
|
|
||||||
FetchContent_MakeAvailable(fast_float)
|
FetchContent_MakeAvailable(fast_float)
|
||||||
@ -552,7 +557,7 @@ You may also use [CPM](https://github.com/cpm-cmake/CPM.cmake), like so:
|
|||||||
CPMAddPackage(
|
CPMAddPackage(
|
||||||
NAME fast_float
|
NAME fast_float
|
||||||
GITHUB_REPOSITORY "fastfloat/fast_float"
|
GITHUB_REPOSITORY "fastfloat/fast_float"
|
||||||
GIT_TAG v8.2.3)
|
GIT_TAG v8.2.5)
|
||||||
```
|
```
|
||||||
|
|
||||||
## Using as single header
|
## Using as single header
|
||||||
@ -564,7 +569,7 @@ if desired as described in the command line help.
|
|||||||
|
|
||||||
You may directly download automatically generated single-header files:
|
You may directly download automatically generated single-header files:
|
||||||
|
|
||||||
<https://github.com/fastfloat/fast_float/releases/download/v8.2.3/fast_float.h>
|
<https://github.com/fastfloat/fast_float/releases/download/v8.2.5/fast_float.h>
|
||||||
|
|
||||||
## Benchmarking
|
## Benchmarking
|
||||||
|
|
||||||
|
|||||||
@ -594,7 +594,7 @@ parse_int_string(UC const *p, UC const *pend, T &value,
|
|||||||
((digits + 0x46464646u) | (digits - 0x30303030u)) & 0x80808080u;
|
((digits + 0x46464646u) | (digits - 0x30303030u)) & 0x80808080u;
|
||||||
uint32_t tz = (uint32_t)countr_zero_32(magic); // 7, 15, 23, 31, or 32
|
uint32_t tz = (uint32_t)countr_zero_32(magic); // 7, 15, 23, 31, or 32
|
||||||
uint32_t nd = (tz == 32) ? 4 : (tz >> 3);
|
uint32_t nd = (tz == 32) ? 4 : (tz >> 3);
|
||||||
nd = (uint32_t)std::min((size_t)nd, len);
|
nd = (uint32_t)(nd < len ? nd : len);
|
||||||
if (nd == 0) {
|
if (nd == 0) {
|
||||||
if (has_leading_zeros) {
|
if (has_leading_zeros) {
|
||||||
value = 0;
|
value = 0;
|
||||||
|
|||||||
@ -1,7 +1,6 @@
|
|||||||
#ifndef FASTFLOAT_DIGIT_COMPARISON_H
|
#ifndef FASTFLOAT_DIGIT_COMPARISON_H
|
||||||
#define FASTFLOAT_DIGIT_COMPARISON_H
|
#define FASTFLOAT_DIGIT_COMPARISON_H
|
||||||
|
|
||||||
#include <algorithm>
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <iterator>
|
#include <iterator>
|
||||||
@ -109,7 +108,7 @@ fastfloat_really_inline FASTFLOAT_CONSTEXPR14 void round(adjusted_mantissa &am,
|
|||||||
if (-am.power2 >= mantissa_shift) {
|
if (-am.power2 >= mantissa_shift) {
|
||||||
// have a denormal float
|
// have a denormal float
|
||||||
int32_t shift = -am.power2 + 1;
|
int32_t shift = -am.power2 + 1;
|
||||||
cb(am, std::min<int32_t>(shift, 64));
|
cb(am, (shift < 64 ? shift : 64));
|
||||||
// check for round-up: if rounding-nearest carried us to the hidden bit.
|
// check for round-up: if rounding-nearest carried us to the hidden bit.
|
||||||
am.power2 = (am.mantissa <
|
am.power2 = (am.mantissa <
|
||||||
(uint64_t(1) << binary_format<T>::mantissa_explicit_bits()))
|
(uint64_t(1) << binary_format<T>::mantissa_explicit_bits()))
|
||||||
|
|||||||
@ -18,7 +18,7 @@
|
|||||||
|
|
||||||
#define FASTFLOAT_VERSION_MAJOR 8
|
#define FASTFLOAT_VERSION_MAJOR 8
|
||||||
#define FASTFLOAT_VERSION_MINOR 2
|
#define FASTFLOAT_VERSION_MINOR 2
|
||||||
#define FASTFLOAT_VERSION_PATCH 3
|
#define FASTFLOAT_VERSION_PATCH 5
|
||||||
|
|
||||||
#define FASTFLOAT_STRINGIZE_IMPL(x) #x
|
#define FASTFLOAT_STRINGIZE_IMPL(x) #x
|
||||||
#define FASTFLOAT_STRINGIZE(x) FASTFLOAT_STRINGIZE_IMPL(x)
|
#define FASTFLOAT_STRINGIZE(x) FASTFLOAT_STRINGIZE_IMPL(x)
|
||||||
@ -313,8 +313,6 @@ fastfloat_strncasecmp3(UC const *actual_mixedcase,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename UC>
|
template <typename UC>
|
||||||
@ -369,8 +367,6 @@ fastfloat_strncasecmp5(UC const *actual_mixedcase,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Compares two ASCII strings in a case insensitive manner.
|
// Compares two ASCII strings in a case insensitive manner.
|
||||||
@ -402,7 +398,7 @@ fastfloat_strncasecmp(UC const *actual_mixedcase, UC const *expected_lowercase,
|
|||||||
size_t sz{8 / (sizeof(UC))};
|
size_t sz{8 / (sizeof(UC))};
|
||||||
for (size_t i = 0; i < length; i += sz) {
|
for (size_t i = 0; i < length; i += sz) {
|
||||||
val1 = val2 = 0;
|
val1 = val2 = 0;
|
||||||
sz = std::min(sz, length - i);
|
sz = sz < (length - i) ? sz : length - i;
|
||||||
::memcpy(&val1, actual_mixedcase + i, sz * sizeof(UC));
|
::memcpy(&val1, actual_mixedcase + i, sz * sizeof(UC));
|
||||||
::memcpy(&val2, expected_lowercase + i, sz * sizeof(UC));
|
::memcpy(&val2, expected_lowercase + i, sz * sizeof(UC));
|
||||||
val1 |= mask;
|
val1 |= mask;
|
||||||
|
|||||||
@ -155,7 +155,7 @@ template <> struct from_chars_caller<std::float32_t> {
|
|||||||
// if std::float32_t is defined, and we are in C++23 mode; macro set for
|
// if std::float32_t is defined, and we are in C++23 mode; macro set for
|
||||||
// float32; set value to float due to equivalence between float and
|
// float32; set value to float due to equivalence between float and
|
||||||
// float32_t
|
// float32_t
|
||||||
float val;
|
float val = 0.0f;
|
||||||
auto ret = from_chars_advanced(first, last, val, options);
|
auto ret = from_chars_advanced(first, last, val, options);
|
||||||
value = val;
|
value = val;
|
||||||
return ret;
|
return ret;
|
||||||
@ -172,7 +172,7 @@ template <> struct from_chars_caller<std::float64_t> {
|
|||||||
// if std::float64_t is defined, and we are in C++23 mode; macro set for
|
// if std::float64_t is defined, and we are in C++23 mode; macro set for
|
||||||
// float64; set value as double due to equivalence between double and
|
// float64; set value as double due to equivalence between double and
|
||||||
// float64_t
|
// float64_t
|
||||||
double val;
|
double val = 0.0;
|
||||||
auto ret = from_chars_advanced(first, last, val, options);
|
auto ret = from_chars_advanced(first, last, val, options);
|
||||||
value = val;
|
value = val;
|
||||||
return ret;
|
return ret;
|
||||||
@ -251,7 +251,7 @@ clinger_fast_path_impl(uint64_t mantissa, int64_t exponent, bool is_negative,
|
|||||||
* parsing options or other parsing custom function implemented by user.
|
* parsing options or other parsing custom function implemented by user.
|
||||||
*/
|
*/
|
||||||
template <typename T, typename UC>
|
template <typename T, typename UC>
|
||||||
FASTFLOAT_CONSTEXPR20 from_chars_result_t<UC>
|
fastfloat_really_inline FASTFLOAT_CONSTEXPR20 from_chars_result_t<UC>
|
||||||
from_chars_advanced(parsed_number_string_t<UC> &pns, T &value) noexcept {
|
from_chars_advanced(parsed_number_string_t<UC> &pns, T &value) noexcept {
|
||||||
static_assert(is_supported_float_type<T>::value,
|
static_assert(is_supported_float_type<T>::value,
|
||||||
"only some floating-point types are supported");
|
"only some floating-point types are supported");
|
||||||
@ -290,7 +290,7 @@ from_chars_advanced(parsed_number_string_t<UC> &pns, T &value) noexcept {
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, typename UC>
|
template <typename T, typename UC>
|
||||||
FASTFLOAT_CONSTEXPR20 from_chars_result_t<UC>
|
fastfloat_really_inline FASTFLOAT_CONSTEXPR20 from_chars_result_t<UC>
|
||||||
from_chars_float_advanced(UC const *first, UC const *last, T &value,
|
from_chars_float_advanced(UC const *first, UC const *last, T &value,
|
||||||
parse_options_t<UC> options) noexcept {
|
parse_options_t<UC> options) noexcept {
|
||||||
|
|
||||||
@ -456,7 +456,7 @@ template <size_t TypeIx> struct from_chars_advanced_caller {
|
|||||||
|
|
||||||
template <> struct from_chars_advanced_caller<1> {
|
template <> struct from_chars_advanced_caller<1> {
|
||||||
template <typename T, typename UC>
|
template <typename T, typename UC>
|
||||||
FASTFLOAT_CONSTEXPR20 static from_chars_result_t<UC>
|
fastfloat_really_inline FASTFLOAT_CONSTEXPR20 static from_chars_result_t<UC>
|
||||||
call(UC const *first, UC const *last, T &value,
|
call(UC const *first, UC const *last, T &value,
|
||||||
parse_options_t<UC> options) noexcept {
|
parse_options_t<UC> options) noexcept {
|
||||||
return from_chars_float_advanced(first, last, value, options);
|
return from_chars_float_advanced(first, last, value, options);
|
||||||
@ -465,7 +465,7 @@ template <> struct from_chars_advanced_caller<1> {
|
|||||||
|
|
||||||
template <> struct from_chars_advanced_caller<2> {
|
template <> struct from_chars_advanced_caller<2> {
|
||||||
template <typename T, typename UC>
|
template <typename T, typename UC>
|
||||||
FASTFLOAT_CONSTEXPR20 static from_chars_result_t<UC>
|
fastfloat_really_inline FASTFLOAT_CONSTEXPR20 static from_chars_result_t<UC>
|
||||||
call(UC const *first, UC const *last, T &value,
|
call(UC const *first, UC const *last, T &value,
|
||||||
parse_options_t<UC> options) noexcept {
|
parse_options_t<UC> options) noexcept {
|
||||||
return from_chars_int_advanced(first, last, value, options);
|
return from_chars_int_advanced(first, last, value, options);
|
||||||
@ -473,7 +473,7 @@ template <> struct from_chars_advanced_caller<2> {
|
|||||||
};
|
};
|
||||||
|
|
||||||
template <typename T, typename UC>
|
template <typename T, typename UC>
|
||||||
FASTFLOAT_CONSTEXPR20 from_chars_result_t<UC>
|
fastfloat_really_inline FASTFLOAT_CONSTEXPR20 from_chars_result_t<UC>
|
||||||
from_chars_advanced(UC const *first, UC const *last, T &value,
|
from_chars_advanced(UC const *first, UC const *last, T &value,
|
||||||
parse_options_t<UC> options) noexcept {
|
parse_options_t<UC> options) noexcept {
|
||||||
return from_chars_advanced_caller<
|
return from_chars_advanced_caller<
|
||||||
|
|||||||
@ -1167,6 +1167,9 @@ TEST_CASE("double.general") {
|
|||||||
// DBL_TRUE_MIN / 2 + 0.0000000000000001e-324
|
// DBL_TRUE_MIN / 2 + 0.0000000000000001e-324
|
||||||
verify("2.4703282292062328e-324", 0x0.0000000000001p-1022);
|
verify("2.4703282292062328e-324", 0x0.0000000000001p-1022);
|
||||||
|
|
||||||
|
verify("0.2470328229206232720e-323", 0.0, std::errc::result_out_of_range);
|
||||||
|
verify("0.2470328229206232721e-323", 0x0.0000000000001p-1022);
|
||||||
|
|
||||||
verify("-2.2222222222223e-322", -0x1.68p-1069);
|
verify("-2.2222222222223e-322", -0x1.68p-1069);
|
||||||
verify("9007199254740993.0", 0x1p+53);
|
verify("9007199254740993.0", 0x1p+53);
|
||||||
verify("860228122.6654514319E+90", 0x1.92bb20990715fp+328);
|
verify("860228122.6654514319E+90", 0x1.92bb20990715fp+328);
|
||||||
@ -1262,8 +1265,13 @@ TEST_CASE("double.general") {
|
|||||||
verify("4.9406564584124654e-324", 0x0.0000000000001p-1022);
|
verify("4.9406564584124654e-324", 0x0.0000000000001p-1022);
|
||||||
verify("2.2250738585072009e-308", 0x0.fffffffffffffp-1022);
|
verify("2.2250738585072009e-308", 0x0.fffffffffffffp-1022);
|
||||||
verify("2.2250738585072014e-308", 0x1p-1022);
|
verify("2.2250738585072014e-308", 0x1p-1022);
|
||||||
|
verify("0.2225073858507201136e-307", 0x0.fffffffffffffp-1022);
|
||||||
|
verify("0.2225073858507201137e-307", 0x1p-1022);
|
||||||
verify("1.7976931348623157e308", 0x1.fffffffffffffp+1023);
|
verify("1.7976931348623157e308", 0x1.fffffffffffffp+1023);
|
||||||
verify("1.7976931348623158e308", 0x1.fffffffffffffp+1023);
|
verify("1.7976931348623158e308", 0x1.fffffffffffffp+1023);
|
||||||
|
verify("1.7976931348623158079e308", std::numeric_limits<double>::max());
|
||||||
|
verify("1.7976931348623158080e308", std::numeric_limits<double>::infinity(),
|
||||||
|
std::errc::result_out_of_range);
|
||||||
verify("4503599627370496.5", 4503599627370496.5);
|
verify("4503599627370496.5", 4503599627370496.5);
|
||||||
verify("4503599627475352.5", 4503599627475352.5);
|
verify("4503599627475352.5", 4503599627475352.5);
|
||||||
verify("4503599627475353.5", 4503599627475353.5);
|
verify("4503599627475353.5", 4503599627475353.5);
|
||||||
@ -1543,6 +1551,8 @@ TEST_CASE("float.general") {
|
|||||||
verify("0.7006492e-45", 0.f, std::errc::result_out_of_range);
|
verify("0.7006492e-45", 0.f, std::errc::result_out_of_range);
|
||||||
// FLT_TRUE_MIN / 2 + 0.0000001e-45
|
// FLT_TRUE_MIN / 2 + 0.0000001e-45
|
||||||
verify("0.7006493e-45", 0x1p-149f);
|
verify("0.7006493e-45", 0x1p-149f);
|
||||||
|
verify("0.7006492321624085354e-45", 0.f, std::errc::result_out_of_range);
|
||||||
|
verify("0.7006492321624085355e-45", 0x1p-149f);
|
||||||
|
|
||||||
// max
|
// max
|
||||||
verify("340282346638528859811704183484516925440", 0x1.fffffep+127f);
|
verify("340282346638528859811704183484516925440", 0x1.fffffep+127f);
|
||||||
@ -1553,6 +1563,9 @@ TEST_CASE("float.general") {
|
|||||||
// that rounds to FLT_MAX
|
// that rounds to FLT_MAX
|
||||||
verify("340282356779733661637539395458142568447",
|
verify("340282356779733661637539395458142568447",
|
||||||
std::numeric_limits<float>::max());
|
std::numeric_limits<float>::max());
|
||||||
|
verify("0.3402823567797336616e39", std::numeric_limits<float>::max());
|
||||||
|
verify("0.3402823567797336617e39", std::numeric_limits<float>::infinity(),
|
||||||
|
std::errc::result_out_of_range);
|
||||||
|
|
||||||
verify("-1e-999", -0.0f, std::errc::result_out_of_range);
|
verify("-1e-999", -0.0f, std::errc::result_out_of_range);
|
||||||
verify("1."
|
verify("1."
|
||||||
@ -1563,6 +1576,8 @@ TEST_CASE("float.general") {
|
|||||||
"175494140627517859246175898662808184331245864732796240031385942718174"
|
"175494140627517859246175898662808184331245864732796240031385942718174"
|
||||||
"6759860647699724722770042717456817626953125e-38",
|
"6759860647699724722770042717456817626953125e-38",
|
||||||
0x1.fffff8p-127f);
|
0x1.fffff8p-127f);
|
||||||
|
verify("1.1754942807573642917e-38", 0x1.fffffcp-127f);
|
||||||
|
verify("1.1754942807573642918e-38", std::numeric_limits<float>::min());
|
||||||
verify_runtime(
|
verify_runtime(
|
||||||
append_zeros("1."
|
append_zeros("1."
|
||||||
"17549414062751785924617589866280818433124586473279624003138"
|
"17549414062751785924617589866280818433124586473279624003138"
|
||||||
|
|||||||
@ -22,7 +22,7 @@ template <typename T> bool test() {
|
|||||||
char const *begin = input.data();
|
char const *begin = input.data();
|
||||||
char const *end = input.data() + input.size();
|
char const *end = input.data() + input.size();
|
||||||
for (size_t i = 0; i < answers.size(); i++) {
|
for (size_t i = 0; i < answers.size(); i++) {
|
||||||
T result_value;
|
T result_value = 0;
|
||||||
while ((begin < end) && (std::isspace(*begin))) {
|
while ((begin < end) && (std::isspace(*begin))) {
|
||||||
begin++;
|
begin++;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -98,7 +98,7 @@ template <typename T> bool test() {
|
|||||||
char const *begin = input.data();
|
char const *begin = input.data();
|
||||||
char const *end = input.data() + input.size();
|
char const *end = input.data() + input.size();
|
||||||
for (size_t i = 0; i < answers.size(); i++) {
|
for (size_t i = 0; i < answers.size(); i++) {
|
||||||
T result_value;
|
T result_value = 0;
|
||||||
while ((begin < end) && (std::isspace(*begin))) {
|
while ((begin < end) && (std::isspace(*begin))) {
|
||||||
begin++;
|
begin++;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user