#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

#1891 in Rust patterns

Download history 2934/week @ 2024-07-27 3160/week @ 2024-08-03 2838/week @ 2024-08-10 2924/week @ 2024-08-17 2407/week @ 2024-08-24 2969/week @ 2024-08-31 3353/week @ 2024-09-07 2952/week @ 2024-09-14 3540/week @ 2024-09-21 2840/week @ 2024-09-28 3828/week @ 2024-10-05 3467/week @ 2024-10-12 2840/week @ 2024-10-19 2543/week @ 2024-10-26 2702/week @ 2024-11-02 1598/week @ 2024-11-09

9,949 downloads per month
Used in 87 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