• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

.github/H03-May-2022-2521

benches/H03-May-2022-5545

src/H03-May-2022-955473

tests/H03-May-2022-3934

.cargo-checksum.jsonH A D03-May-202289 11

.cargo_vcs_info.jsonH A D16-Jun-202074 65

.gitignoreH A D25-Apr-201918 32

Cargo.tomlH A D16-Jun-2020978 2624

Cargo.toml.orig-cargoH A D16-Jun-2020489 1513

LICENSE-APACHEH A D25-Apr-201910.6 KiB202169

LICENSE-MITH A D25-Apr-20191,023 2421

README.mdH A D14-Jun-20203.4 KiB8157

README.md

1dtoa
2====
3
4[<img alt="github" src="https://img.shields.io/badge/github-dtolnay/dtoa-8da0cb?style=for-the-badge&labelColor=555555&logo=github" height="20">](https://github.com/dtolnay/dtoa)
5[<img alt="crates.io" src="https://img.shields.io/crates/v/dtoa.svg?style=for-the-badge&color=fc8d62&logo=rust" height="20">](https://crates.io/crates/dtoa)
6[<img alt="docs.rs" src="https://img.shields.io/badge/docs.rs-dtoa-66c2a5?style=for-the-badge&labelColor=555555&logoColor=white&logo=data:image/svg+xml;base64,PHN2ZyByb2xlPSJpbWciIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgdmlld0JveD0iMCAwIDUxMiA1MTIiPjxwYXRoIGZpbGw9IiNmNWY1ZjUiIGQ9Ik00ODguNiAyNTAuMkwzOTIgMjE0VjEwNS41YzAtMTUtOS4zLTI4LjQtMjMuNC0zMy43bC0xMDAtMzcuNWMtOC4xLTMuMS0xNy4xLTMuMS0yNS4zIDBsLTEwMCAzNy41Yy0xNC4xIDUuMy0yMy40IDE4LjctMjMuNCAzMy43VjIxNGwtOTYuNiAzNi4yQzkuMyAyNTUuNSAwIDI2OC45IDAgMjgzLjlWMzk0YzAgMTMuNiA3LjcgMjYuMSAxOS45IDMyLjJsMTAwIDUwYzEwLjEgNS4xIDIyLjEgNS4xIDMyLjIgMGwxMDMuOS01MiAxMDMuOSA1MmMxMC4xIDUuMSAyMi4xIDUuMSAzMi4yIDBsMTAwLTUwYzEyLjItNi4xIDE5LjktMTguNiAxOS45LTMyLjJWMjgzLjljMC0xNS05LjMtMjguNC0yMy40LTMzLjd6TTM1OCAyMTQuOGwtODUgMzEuOXYtNjguMmw4NS0zN3Y3My4zek0xNTQgMTA0LjFsMTAyLTM4LjIgMTAyIDM4LjJ2LjZsLTEwMiA0MS40LTEwMi00MS40di0uNnptODQgMjkxLjFsLTg1IDQyLjV2LTc5LjFsODUtMzguOHY3NS40em0wLTExMmwtMTAyIDQxLjQtMTAyLTQxLjR2LS42bDEwMi0zOC4yIDEwMiAzOC4ydi42em0yNDAgMTEybC04NSA0Mi41di03OS4xbDg1LTM4Ljh2NzUuNHptMC0xMTJsLTEwMiA0MS40LTEwMi00MS40di0uNmwxMDItMzguMiAxMDIgMzguMnYuNnoiPjwvcGF0aD48L3N2Zz4K" height="20">](https://docs.rs/dtoa)
7[<img alt="build status" src="https://img.shields.io/github/workflow/status/dtolnay/dtoa/CI/master?style=for-the-badge" height="20">](https://github.com/dtolnay/dtoa/actions?query=branch%3Amaster)
8
9This crate provides fast functions for printing floating-point primitives to an
10[`io::Write`]. The implementation is a straightforward Rust port of [Milo Yip]'s
11C++ implementation [dtoa.h]. The original C++ code of each function is included
12in comments.
13
14See also [`itoa`] for printing integer primitives.
15
16*Version requirement: rustc 1.0+*
17
18[`io::Write`]: https://doc.rust-lang.org/std/io/trait.Write.html
19[Milo Yip]: https://github.com/miloyip
20[dtoa.h]: https://github.com/miloyip/rapidjson/blob/master/include/rapidjson/internal/dtoa.h
21[`itoa`]: https://github.com/dtolnay/itoa
22
23```toml
24[dependencies]
25dtoa = "0.4"
26```
27
28<br>
29
30## Performance (lower is better)
31
32![performance](https://raw.githubusercontent.com/dtolnay/dtoa/master/performance.png)
33
34<br>
35
36## Examples
37
38```rust
39use std::io;
40
41fn main() -> io::Result<()> {
42    // Write to a vector or other io::Write.
43    let mut buf = Vec::new();
44    dtoa::write(&mut buf, 2.71828f64)?;
45    println!("{:?}", buf);
46
47    // Write to a stack buffer.
48    let mut bytes = [b'\0'; 20];
49    let n = dtoa::write(&mut bytes[..], 2.71828f64)?;
50    println!("{:?}", &bytes[..n]);
51
52    Ok(())
53}
54```
55
56The function signature is:
57
58```rust
59fn write<W: io::Write, V: dtoa::Floating>(writer: W, value: V) -> io::Result<()>;
60```
61
62where `dtoa::Floating` is implemented for f32 and f64. The return value gives
63the number of bytes written.
64
65<br>
66
67#### License
68
69<sup>
70Licensed under either of <a href="LICENSE-APACHE">Apache License, Version
712.0</a> or <a href="LICENSE-MIT">MIT license</a> at your option.
72</sup>
73
74<br>
75
76<sub>
77Unless you explicitly state otherwise, any contribution intentionally submitted
78for inclusion in this crate by you, as defined in the Apache-2.0 license, shall
79be dual licensed as above, without any additional terms or conditions.
80</sub>
81