Crate teju

Crate teju 

Source
Expand description

Rust implementation of Tejú Jaguá, a fast algorithm for converting a floating point number to a (decimal) string.

The interface mimics that of Ryu.

§Usage

let mut buffer = teju::Buffer::new();
let printed = buffer.format_finite(1.234);
assert_eq!(printed, "1.234");

Numbers whose decimal representation is short are written as decimals; numbers with lots of zeroes are written in scientific notation. To force either way, use format_dec or format_exp, respectively.

assert_eq!(teju::Buffer::new().format(1e3), "1000.0");
assert_eq!(teju::Buffer::new().format_dec(1e3), "1000.0");
assert_eq!(teju::Buffer::new().format_exp(1e3), "1e3");

assert_eq!(teju::Buffer::new().format(1e30), "1e30");
assert_eq!(teju::Buffer::new().format_exp(1e30), "1e30");
assert_eq!(teju::Buffer::new().format_dec(1e30), "1000000000000000000000000000000.0");

§Performance

Microbenchmark chart comparing teju with ryu and std

Structs§

Buffer
Safe API for formatting floating point numbers to text.

Traits§

Float
A floating point type which teju can serialise into a string.