1
- fast-float
2
- ==========
1
+ fast-float2
2
+ ===========
3
3
4
- [ ![ Build] ( https://github.com/aldanor /fast-float-rust/workflows/CI/badge.svg )] ( https://github.com/aldanor /fast-float-rust/actions?query=branch%3Amaster )
5
- [ ![ Latest Version] ( https://img.shields.io/crates/v/fast-float .svg )] ( https://crates.io/crates/fast-float )
6
- [ ![ Documentation] ( https://docs.rs/fast-float /badge.svg )] ( https://docs.rs/fast-float )
4
+ [ ![ Build] ( https://github.com/Alexhuszagh /fast-float-rust/workflows/CI/badge.svg )] ( https://github.com/Alexhuszagh /fast-float-rust/actions?query=branch%3Amaster )
5
+ [ ![ Latest Version] ( https://img.shields.io/crates/v/fast-float2 .svg )] ( https://crates.io/crates/fast-float2 )
6
+ [ ![ Documentation] ( https://docs.rs/fast-float2 /badge.svg )] ( https://docs.rs/fast-float2 )
7
7
[ ![ Apache 2.0] ( https://img.shields.io/badge/License-Apache%202.0-blue.svg )] ( https://opensource.org/licenses/Apache-2.0 )
8
8
[ ![ MIT] ( https://img.shields.io/badge/License-MIT-blue.svg )] ( https://opensource.org/licenses/MIT )
9
9
[ ![ Rustc 1.37+] ( https://img.shields.io/badge/rustc-1.37+-lightgray.svg )] ( https://blog.rust-lang.org/2019/08/15/Rust-1.37.0.html )
@@ -12,7 +12,7 @@ This crate provides a super-fast decimal number parser from strings into floats.
12
12
13
13
``` toml
14
14
[dependencies ]
15
- fast-float = " 0.2"
15
+ fast-float2 = " 0.2.1 "
16
16
```
17
17
18
18
There are no dependencies and the crate can be used in a no_std context by disabling the "std" feature.
@@ -21,10 +21,10 @@ There are no dependencies and the crate can be used in a no_std context by disab
21
21
22
22
## Usage
23
23
24
- There's two top-level functions provided:
25
- [ ` parse() ` ] ( https://docs.rs/fast-float/latest/fast_float/fn.parse.html ) and
24
+ There's two top-level functions provided:
25
+ [ ` parse() ` ] ( https://docs.rs/fast-float/latest/fast_float/fn.parse.html ) and
26
26
[ ` parse_partial() ` ] ( https://docs.rs/fast-float/latest/fast_float/fn.parse_partial.html ) , both taking
27
- either a string or a bytes slice and parsing the input into either ` f32 ` or ` f64 ` :
27
+ either a string or a bytes slice and parsing the input into either ` f32 ` or ` f64 ` :
28
28
29
29
- ` parse() ` treats the whole string as a decimal number and returns an error if there are
30
30
invalid characters or if the string is empty.
@@ -39,12 +39,12 @@ Example:
39
39
``` rust
40
40
// Parse the entire string as a decimal number.
41
41
let s = " 1.23e-02" ;
42
- let x : f32 = fast_float :: parse (s ). unwrap ();
42
+ let x : f32 = fast_float2 :: parse (s ). unwrap ();
43
43
assert_eq! (x , 0.0123 );
44
44
45
45
// Parse as many characters as possible as a decimal number.
46
46
let s = " 1.23e-02foo" ;
47
- let (x , n ) = fast_float :: parse_partial :: <f32 , _ >(s ). unwrap ();
47
+ let (x , n ) = fast_float2 :: parse_partial :: <f32 , _ >(s ). unwrap ();
48
48
assert_eq! (x , 0.0123 );
49
49
assert_eq! (n , 8 );
50
50
assert_eq! (& s [n .. ], " foo" );
@@ -53,19 +53,22 @@ assert_eq!(&s[n..], "foo");
53
53
## Details
54
54
55
55
This crate is a direct port of Daniel Lemire's [ ` fast_float ` ] ( https://github.com/fastfloat/fast_float )
56
- C++ library (valuable discussions with Daniel while porting it helped shape the crate and get it to
56
+ C++ library (valuable discussions with Daniel while porting it helped shape the crate and get it to
57
57
the performance level it's at now), with some Rust-specific tweaks. Please see the original
58
58
repository for many useful details regarding the algorithm and the implementation.
59
59
60
- The parser is locale-independent. The resulting value is the closest floating-point values (using either
61
- ` f32 ` or ` f64 ` ), using the "round to even" convention for values that would otherwise fall right in-between
62
- two values. That is, we provide exact parsing according to the IEEE standard.
60
+ The parser is locale-independent. The resulting value is the closest floating-point values (using either
61
+ ` f32 ` or ` f64 ` ), using the "round to even" convention for values that would otherwise fall right in-between
62
+ two values. That is, we provide exact parsing according to the IEEE standard.
63
63
64
64
Infinity and NaN values can be parsed, along with scientific notation.
65
65
66
66
Both little-endian and big-endian platforms are equally supported, with extra optimizations enabled
67
67
on little-endian architectures.
68
68
69
+ Since [ fast-float-rust] ( https://github.com/aldanor/fast-float-rust ) is unmaintained, this is a fork
70
+ containing the patches and security updates.
71
+
69
72
## Testing
70
73
71
74
There are a few ways this crate is tested:
@@ -80,7 +83,7 @@ There are a few ways this crate is tested:
80
83
## Performance
81
84
82
85
The presented parser seems to beat all of the existing C/C++/Rust float parsers known to us at the
83
- moment by a large margin, in all of the datasets we tested it on so far – see detailed benchmarks
86
+ moment by a large margin, in all of the datasets we tested it on so far – see detailed benchmarks
84
87
below (the only exception being the original fast_float C++ library, of course – performance of
85
88
which is within noise bounds of this crate). On modern machines like Apple M1, parsing throughput
86
89
can reach up to 1.5 GB/s.
@@ -103,7 +106,7 @@ C++ library, here are few brief notes:
103
106
104
107
## Benchmarks
105
108
106
- Below are tables of best timings in nanoseconds for parsing a single number
109
+ Below are tables of best timings in nanoseconds for parsing a single number
107
110
into a 64-bit float.
108
111
109
112
#### Intel i7-4771
@@ -169,12 +172,12 @@ AMD Rome, Linux, Rust 1.49.
169
172
170
173
#### Notes
171
174
172
- - The two test files referred above can be found in
175
+ - The two test files referred above can be found in
173
176
[ this] ( https://github.com/lemire/simple_fastfloat_benchmark ) repository.
174
177
- The Rust part of the table (along with a few other benchmarks) can be generated via
175
178
the benchmark tool that can be found under ` extras/simple-bench ` of this repo.
176
179
- The C/C++ part of the table (along with a few other benchmarks and parsers) can be
177
- generated via a C++ utility that can be found in
180
+ generated via a C++ utility that can be found in
178
181
[ this] ( https://github.com/lemire/simple_fastfloat_benchmark ) repository.
179
182
180
183
<br >
0 commit comments