You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-[Comparison to Algorithm M and dtoa](#comparison-to-algorithm-m-and-dtoa)
17
+
-[Algorithm Background and Comparison](#algorithm-background-and-comparison)
18
18
19
19
# Features
20
20
@@ -37,13 +37,15 @@ Float parsing is difficult to do correctly, and major bugs have been found in im
37
37
38
38
Although Lexical may contain bugs leading to rounding error, it is tested against a comprehensive suite of random-data and near-halfway representations, and should be fast and correct for the vast majority of use-cases.
39
39
40
+
Finally, due to the heavy use of unsafe code, Lexical-core is fuzzed using cargo-fuzz, to avoid memory errors.
41
+
40
42
# Caveats
41
43
42
44
Lexical uses unsafe code in the back-end for performance, and therefore may introduce memory-safety issues. Although the code is tested with wide variety of inputs to minimize the risk of memory-safety bugs, and then unittests are run are under Valgrind, no guarantees are made and you should use it at your own risk.
43
45
44
46
Finally, for non-decimal (base 10) floats, lexical's float-to-string implementation is lossy, resulting in rounding for a small subset of inputs (up to 0.1% of the total value).
45
47
46
-
# Details
48
+
# Implementation Details
47
49
48
50
## Float to String
49
51
@@ -68,9 +70,9 @@ To use Algorithm M, use the feature `algorithm_m` when compiling lexical.
68
70
69
71
## Arbitrary-Precision Arithmetic
70
72
71
-
Lexical uses arbitrary-precision arithmetic to exactly represent strings between two floating-point representations with more than 36 digits, with various optimizations for multiplication and division relative to Rust's current implementation. The arbitrary-precision arithmetic logic is not independent on memory allocation: the default slow-path algorithm only uses the stack, while Algorithm M uses the heap.
73
+
Lexical uses arbitrary-precision arithmetic to exactly represent strings between two floating-point representations with more than 36 digits, with various optimizations for multiplication and division relative to Rust's current implementation. The arbitrary-precision arithmetic logic is not independent on memory allocation: the default slow-path algorithm only uses the stack, and Algorithm M only uses the heap when the `radix` feature is enabled.
72
74
73
-
## Comparison to Algorithm M
75
+
## Algorithm Background and Comparison
74
76
75
77
For close-to-halfway representations of a decimal string `s`, where `s` is close between two representations, `b` and the next float `b+u`, arbitrary-precision arithmetic is used to determine the correct representation. This means `s` is close to `b+h`, where `h` is the halfway point between `b` and `b+u`.
0 commit comments