Function float_fast_print::write_f64_shortest[][src]

pub fn write_f64_shortest<W: Write>(writer: W, num: f64) -> Result<usize>

Converts the given f32 number to a short round-trip base-10 representation using the efficient Ryū algorithm by Ulf Adams.

This function is ideal for exporting bulk floating-point data to text formats, such as CSV, JSON, or XLSX (Excel 2007 and later).

Examples

use float_fast_print::write_f64_shortest;

let mut buffer: Vec<u8> = Vec::with_capacity(32);
write_f64_shortest(&mut buffer, 502.1239e29).unwrap();
assert_eq!(&buffer, b"5.021239e31");

Safety

Unlike some other similar code such as the dtoa crate, this function uses 100% safe Rust code, does not have any external dependencies, does not include C code, and does not require a heap.

Unlike write_f32_shortest, it is infeasible to test all 2^64 possible input numbers.