File: README.md

package info (click to toggle)
rust-ryu-floating-decimal 0.1.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 184 kB
  • sloc: makefile: 4
file content (21 lines) | stat: -rw-r--r-- 888 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# Ryu Floating Decimal

This crate directly copies the internals of the [ryu rust crate](https://github.com/dtolnay/ryu), 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](https://github.com/dtolnay/ryu) for benchmarks and other information.

## Example

```rust
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](https://github.com/torrencem/ryu-floating-decimal/blob/master/LICENSE-APACHE), copied from [the original crate](https://github.com/dtolnay/ryu)