#decimal #floating #convert #ryu #floating-point #f32 #f2d

ryu_floating_decimal

Fast floating point to floating decimal conversion. See the crate 'ryu' for more details

1 unstable release

Uses old Rust 2015

0.1.0 Jun 1, 2020

#2187 in Rust patterns

Download history 1926/week @ 2024-03-14 2006/week @ 2024-03-21 1702/week @ 2024-03-28 1688/week @ 2024-04-04 2023/week @ 2024-04-11 1784/week @ 2024-04-18 2634/week @ 2024-04-25 2416/week @ 2024-05-02 2455/week @ 2024-05-09 2299/week @ 2024-05-16 1925/week @ 2024-05-23 2580/week @ 2024-05-30 2024/week @ 2024-06-06 2193/week @ 2024-06-13 2550/week @ 2024-06-20 1482/week @ 2024-06-27

8,613 downloads per month
Used in 55 crates (via pretty_dtoa)

Apache-2.0

74KB
1.5K SLoC

Ryu Floating Decimal

This crate directly copies the internals of the ryu rust crate, exposing some useful functions and types for more flexible float printing.

This crate exposes the functions d2d and f2d, which convert from f64 to FloatingDecimal64 and f32 to FloatingDecimal32 respectively. These floating decimals can be converted to strings in a custom way.

See the original crate for benchmarks and other information.

Example

use ryu_floating_decimal::f2d;
let value: f32 = 12.091;
let decimal = f2d(value);
assert_eq!(decimal.mantissa, 12091);
assert_eq!(decimal.exponent, -3);

License

Licensed under Apache License, Version 2.0, copied from the original crate


lib.rs:

This crate copies the internals of the ryu rust crate, exposing some useful functions and types for more flexible float printing. This crate exposes the functions d2d and f2d, which convert from f64 to FloatingDecimal64 and f32 to FloatingDecimal32 respectively. These floating decimals can be converted to strings in a custom way.

Dependencies

~105KB